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. ComboBoxStyle trouble changing style
Forum Updated to NodeBB v4.3 + New Features

ComboBoxStyle trouble changing style

Scheduled Pinned Locked Moved QML and Qt Quick
comboboxbackgroundstyle
2 Posts 2 Posters 1.1k Views 2 Watching
  • 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.
  • P Offline
    P Offline
    Pheelbert
    wrote on last edited by
    #1

    I don't see the changed background and I have no clue how to change the arrow and delegates afterwards..

    ComboBox {
        anchors.left: parent.left
        anchors.leftMargin: 20
        currentIndex: 0
        model: ListModel {
            ListElement { text: "Test1"; }
            ListElement { text: "Test2"; }
        }
        style: ComboBoxStyle {
            background: Rectangle {
                color: "red"
                anchors.fill: parent
            }
            label: Label {
                text: control.currentText
                color: "blue"
                font.pointSize: 16
            }
        }
    }
    

    Thanks for any help!

    p3c0P 1 Reply Last reply
    0
    • P Pheelbert

      I don't see the changed background and I have no clue how to change the arrow and delegates afterwards..

      ComboBox {
          anchors.left: parent.left
          anchors.leftMargin: 20
          currentIndex: 0
          model: ListModel {
              ListElement { text: "Test1"; }
              ListElement { text: "Test2"; }
          }
          style: ComboBoxStyle {
              background: Rectangle {
                  color: "red"
                  anchors.fill: parent
              }
              label: Label {
                  text: control.currentText
                  color: "blue"
                  font.pointSize: 16
              }
          }
      }
      

      Thanks for any help!

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

      Hi @Pheelbert,
      if you meant changing the background of dropdown list then you will need to do it in __dropDownStyle private property for now.
      eg: inside ComboBoxStyle

      __dropDownStyle: MenuStyle {
          itemDelegate.label: Text {
              width:200
              height: 80
              color: "blue"
              text: styleData.text
          }
      
          itemDelegate.background: Rectangle {
              color: styleData.selected ? "darkGray" : "transparent"
          }
      }
      

      And to add an arrow you can just use an Image inside the background: Rectangle { component.

      157

      1 Reply Last reply
      1

      • Login

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