Search code examples
qtqmlmaterial-designthemes

QML: ComboBox applying Material them


I'm not able to set the dark material theme on combobox menù meanwhile it works on the combobox itself.

Some suggestion?

n.b I'm working on a larger project with QT Design Studio 4.2

enter image description here
enter image description here

enter image description here

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtMultimedia 5.15
import VenusView_UI 1.0
import QtGraphicalEffects 1.15
import QtQuick.Controls.Material 2.15
import QtQuick.Controls.Styles 1.4

Rectangle {
    id: rectangle
    width: Constants.width
    height: Constants.height
    color: "#2a2929"
    border.width: 4
    property bool rec_clicked: true
    Material.theme: Material.Dark
    Material.accent: Material.Indigo
    ComboBox {
            id: comboBox
            x: 40
            y: 425
            displayText: "Resolution"
            model: ListModel{
                ListElement{
                    text:"4K"
                }
                ListElement{
                    text:"Full-HD"
                }
                ListElement{
                    text:"HD-Ready"
                }
            }

            onActivated: {
                        comboBox.displayText = comboBox.currentText
                        console.log("Elemento selezionato: " + comboBox.currentText)
                    }
        }
}

Solution

  • This might be a bug, because the documentation states

    All attributes can be specified for any window or item, and they automatically propagate to children in the same manner as fonts.

    It seems like the propagation to the children isn't working when those properties aren't set on Window or ApplicationWindow. This isn't a Qt Design Studio only issue, because I get the same faulty behavior when running the application in Qt Creator as well. The solution in your case would be to put those two lines and the necessary import into App.qml.

    Material.theme: Material.Dark
    Material.accent: Material.Indigo