【发布时间】:2018-04-08 23:09:02
【问题描述】:
不幸的是,我很难找到关于 QtQuick.Controls 更高版本的大量文档。
我有以下问题:我创建了一个 80x80 的按钮,没问题,但是当我决定尝试一下 Material 风格时。
当我有一个按钮宽度默认样式时,它的正确高度为 80。当我使用 Material 样式时,高度看起来不同,您可以在图片上看到:橙色线是 80x3 像素,在第一个按钮上它高于按钮,而第二个按钮(默认样式的按钮)则可以。
为什么会出现这种行为以及如何解决?
第一个按钮的代码(第二个是相同的,只是在配置中使用默认样式)。
Button {
id: testButton
width: 80
height: 80
z: 1
anchors.top: parent.top
anchors.left: parent.left
//Material.elevation: 3
Material.background: "#404244"
highlighted: true
contentItem: Rectangle {
anchors.fill: parent
opacity: 0.0
Text {
text: "test1"
color: "white"
font.pixelSize: 26
anchors.top: parent.top
anchors.topMargin: 15
anchors.horizontalCenter: parent.horizontalCenter
}
Text {
text: "test2"
color: "white"
font.pixelSize: 14
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
anchors.horizontalCenter: parent.horizontalCenter
}
}
Rectangle {
color: "#ff5e00"
width: 4
height: 80
}
}
【问题讨论】:
标签: qt qml material-design qtquick2 qtquickcontrols2