我有一个简单的 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
并设置某些 Material 特定属性不会应用 Material 主题。如果使用此处描述的方法之一设置主题,则将使用它们:
关于qt - Material 主题似乎在 QML 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38739643/