我有一个简单的 QML,里面有一个
ApplicationWindow
、RowLayout
和一堆 Buttons
。我已按照 the docs应用了 Qt Quick Controls 2
Material
主题,但没有任何改变。怎么了?
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3
ApplicationWindow {
Material.theme: Material.Dark
Material.accent: Material.Orange
id: window
visible: true
RowLayout {
anchors.horizontalCenter: window.horizontalCenter
anchors.bottomMargin: 32
Button {
text: "A"
}
Button {
text: "B"
}
Button {
text: "C"
}
}
}
导入
QtQuick.Controls.Material 2.0
并设置某些材质特定属性不会应用材质主题。如果使用此处描述的方法之一设置主题,将使用它们:
在main.cpp中添加QQuickStyle::setStyle("Material");