qtthemesqmlqtquickcontrols2

Material theme doesn't seem to work in QML


I have a simple QML with an ApplicationWindow, RowLayout and a bunch of Buttons inside. I have applied the Qt Quick Controls 2 Material theme as per the docs, but nothing changed. What's wrong?

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"
        }
    }
}

Solution

  • Importing QtQuick.Controls.Material 2.0 and setting some Material specific properties do not apply the Material theme. They will be used if the theme is set using one of the methods described here:

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