[SOLVED] Combobox styling

  • How to use ComboboxStyle::background property? I tried this but it`s not working

    Rectangle {
        id: mainRect
        width: 500
        height: 500
            id: dataModel
            ListElement{ text: "Day" }
            ListElement{ text: "Week" }
            ListElement{ text: "Month" }
            ListElement{ text: "Year" }
        ComboBox {
            id: box
            model: dataModel
            style: ComboBoxStyle{
                background: Rectangle{
                    color: "red"
                label: Text{
                    text: control.currentText
            anchors.centerIn: parent

    I see only text in output (not clickable). What i`m doing wrong?

  • Moderators

    @xumuk Provide implicitWidth and implicitHeight for the Rectangle.

    implicitWidth: 120
    implicitHeight: 20

  • Moderators

    @xumuk Please mark it as solved if it worked so that others may understand that it has solution.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.