Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED] Combobox styling
QtWS25 Last Chance

[SOLVED] Combobox styling

Scheduled Pinned Locked Moved QML and Qt Quick
qt quickqmlcombobox style
3 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xumuk
    wrote on last edited by xumuk
    #1

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

    Rectangle {
        id: mainRect
    
        width: 500
        height: 500
    
        ListModel{
            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?

    p3c0P 2 Replies Last reply
    0
    • X xumuk

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

      Rectangle {
          id: mainRect
      
          width: 500
          height: 500
      
          ListModel{
              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?

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @xumuk Provide implicitWidth and implicitHeight for the Rectangle.

      implicitWidth: 120
      implicitHeight: 20
      

      157

      1 Reply Last reply
      1
      • X xumuk

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

        Rectangle {
            id: mainRect
        
            width: 500
            height: 500
        
            ListModel{
                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?

        p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #3

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

        157

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved