我有一个简单的QML,其中ApplicationWindow
,RowLayout
和一堆Buttons
里面。我已经按照the docs应用了Qt Quick Controls 2 Material
主题,但没有任何变化。怎么了?材质主题似乎不适用于QML
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"
}
}
}
你使用'QQmlApplicationEngine'在C++中加载'ApplicationWindow':如果主题是使用此处介绍的方法之一设置将使用它们?似乎需要从QML控制一些属性。参见Qt文档:http://doc.qt.io/qt-5/qtquickcontrols2-gettingstarted.html –