QML 对话框的固定大小
Fixed size for QML Dialog
我想禁止调整以下 Dialog
window:
Dialog {
id: aboutDialog
width: 300
height: 200
title: "About"
standardButtons: StandardButton.Ok
GridLayout {
rows: 2
columns: 2
Text { text: "Some:"; font.bold: true; }
Text { text: "text"; }
Text { text: "and:"; font.bold: true }
Text { text: "another"; }
}
}
为什么没有像resizable: false
这样的属性?或者有没有?
如果我添加 minimumWidth
属性,则会出现错误:Cannot assign to non-existent property "minimumWidth"
我怎样才能实现我的目标?
upd. Filip 帮助我回答了他的问题,但是,为了使这个 window 不可调整大小,我必须这样写:
width: 300
minimumWidth: 300
maximumWidth: 300
height: 200
minimumHeight: 200
maximumHeight: 200
而不是像这样的东西:resizable: false
。就是这样的任务行数有点多。
如果您需要 window 不可调整大小,则不能使用 Dialog
对象。这是 docs:
的片段
Note: do not attempt to bind the width or height of the dialog to the
width or height of its content, because Dialog already tries to size
itself to the content. If your goal is to change or eliminate the
margins, you must override contentItem. If your goal is simply to show
a window (whether modal or not), and your platform supports it, it is
simpler to use Window instead.
Window
可以有最小和最大尺寸。设置相同的最大值和最小值会使 Window
不可调整大小。我猜你只需要向它添加一个确定按钮,你就会得到你需要的东西。
我想禁止调整以下 Dialog
window:
Dialog {
id: aboutDialog
width: 300
height: 200
title: "About"
standardButtons: StandardButton.Ok
GridLayout {
rows: 2
columns: 2
Text { text: "Some:"; font.bold: true; }
Text { text: "text"; }
Text { text: "and:"; font.bold: true }
Text { text: "another"; }
}
}
为什么没有像resizable: false
这样的属性?或者有没有?
如果我添加 minimumWidth
属性,则会出现错误:Cannot assign to non-existent property "minimumWidth"
我怎样才能实现我的目标?
upd. Filip 帮助我回答了他的问题,但是,为了使这个 window 不可调整大小,我必须这样写:
width: 300
minimumWidth: 300
maximumWidth: 300
height: 200
minimumHeight: 200
maximumHeight: 200
而不是像这样的东西:resizable: false
。就是这样的任务行数有点多。
如果您需要 window 不可调整大小,则不能使用 Dialog
对象。这是 docs:
Note: do not attempt to bind the width or height of the dialog to the width or height of its content, because Dialog already tries to size itself to the content. If your goal is to change or eliminate the margins, you must override contentItem. If your goal is simply to show a window (whether modal or not), and your platform supports it, it is simpler to use Window instead.
Window
可以有最小和最大尺寸。设置相同的最大值和最小值会使 Window
不可调整大小。我猜你只需要向它添加一个确定按钮,你就会得到你需要的东西。