Qt5.10,Windows 10桌面。
以下QML代码:
import QtQuick 2.10
import QtQuick.Window 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
Window {
visible: true
width: 250
height: 100
title: qsTr("My app")
GridLayout
{
columns: 2
Label {
text: "Setting1:"
}
ComboBox {
model: ["100%", "90%", "80%", "70%", "60%", "50%", "40%", "30%"]
}
CheckBox {
id: tidle
text: "Setting2:"
}
ComboBox {
model: ["90%", "80%", "70%", "60%", "50%", "40%", "30%"]
enabled: tidle.checked
}
}
}
给出以下结果:
这对我来说很糟糕:
1) "Setting1“标签和复选框没有明显对齐。
( 2)与文本大小相比,复选框和ComboBox大小过大。
我是错过了什么还是这是正常的行为?
发布于 2018-03-31 17:31:43
这是正常的行为。
控制具有以下布局:
例如,Label
的填充值为0,另一方面,如果CheckBox
有它,那么它们是对齐的,有两种可能的解决方案:
CheckBox {
id: tidle
text: "Setting2:"
leftPadding: 0
}
Label {
text: "Setting1:"
leftPadding : tidle.leftPadding
}
...
CheckBox {
id: tidle
text: "Setting2:"
}
Qt提供了以下自定义Control
的指导方针:
对于ComboBox
的大小,您可以使用FontMetrics
来计算适当的大小,在我的例子中,我是在Linux中,这是不必要的。
https://stackoverflow.com/questions/49590221
复制相似问题