2016-08-03 60 views
2

我有一个简单的QML,其中ApplicationWindowRowLayout和一堆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" 
     } 
    } 
} 
+0

你使用'QQmlApplicationEngine'在C++中加载'ApplicationWindow':如果主题是使用此处介绍的方法之一设置将使用它们?似乎需要从QML控制一些属性。参见Qt文档:http://doc.qt.io/qt-5/qtquickcontrols2-gettingstarted.html –

回答

4

导入QtQuick.Controls.Material 2.0并设置一些材质特定属性不应用材质主题。

http://doc.qt.io/qt-5/qtquickcontrols2-styles.html

+0

啊!谢谢。太糟糕了,这不是我用作参考的页面。 Qt文档通常很好,但有时太分散。 –

+0

@VioletGiraffe:https://codereview.qt-project.org/#/c/166834/ – Mitch

+0

@Mitch:干得好,先生:) –