Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
        }
    }
}
like image 786
Violet Giraffe Avatar asked Aug 03 '16 09:08

Violet Giraffe


1 Answers

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

like image 95
Yoann Quenach de Quivillic Avatar answered Nov 03 '22 04:11

Yoann Quenach de Quivillic