Skip to content

Commit 94a0473

Browse files
committed
fix: ensure dynamic width binding in QML preview
1. Changed static width assignment to dynamic binding using Qt.binding 2. The preview now automatically adjusts when container width changes 3. Fixes issue where preview wouldn't resize with window 4. Maintains better visual consistency during runtime adjustments fix: 修复 QML 预览中的动态宽度绑定问题 1. 将静态宽度分配改为使用 Qt.binding 的动态绑定 2. 预览现在会在容器宽度变化时自动调整 3. 修复了预览不会随窗口调整大小的问题 4. 在运行时调整时保持更好的视觉一致性
1 parent d86e2e4 commit 94a0473

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

examples/exhibition/ViewQMLSource.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ColumnLayout {
5454
var obj = Qt.createQmlObject(edit.text, codePreview, url.toString().replace(".qml", "_temporary.qml"))
5555
globalObject.replace(lastPreview, obj)
5656
lastPreview = obj
57-
obj.width = codePreview.width
57+
obj.width = Qt.binding(function () { return codePreview.width })
5858
errorMessage.text = ""
5959
} catch (error) {
6060
errorMessage.text = String(error.lineNumber ? error.lineNumber : "未知") + "行,"

0 commit comments

Comments
 (0)