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. Combobox with multiple column
Qt 6.11 is out! See what's new in the release blog

Combobox with multiple column

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 2.3k 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.
  • J Offline
    J Offline
    jimcad
    wrote on last edited by jimcad
    #1

    I'm trying display Qt Quick Control ComboBox with multiple column such as here http://www.codeproject.com/KB/combobox/MultiColumnCombo/comboOpen.jpg

    I have done this in widget based ui

    ui->comboBox->setModel(model);
    ui->comboBox->setView(myView);
    

    but how this can be done with QML and Qt Quick Controls? Any ideas?

    Thanks in advanced!

    1 Reply Last reply
    1
    • J Offline
      J Offline
      jimcad
      wrote on last edited by
      #2

      Hmmm.... Maybe I can use ListView. What is the best way to show it in popup?

      p3c0P 1 Reply Last reply
      0
      • R Offline
        R Offline
        ReinaldoJr
        wrote on last edited by
        #3

        Hi,

        Create CustomComboBox Inherit QComboBox.
        Reimplemented showPopup() method.

        void CustomComboBox::showPopup()
         {
          //create/populate QTableWidget
          //set windowflags  
          //calculate position and size
          //and show()   tablewidget   :-)
         }
        
        1 Reply Last reply
        0
        • J jimcad

          Hmmm.... Maybe I can use ListView. What is the best way to show it in popup?

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

          Hi @jimcad
          AFAIK you can try by using ComboBoxStyle. In it there are still some private properties which can be taken advantage of. For eg. __dropDownStyle which can be used to modify the drop down.

          model: ListModel {
              id: cbItems
              ListElement { text: "Banana"; color: "Yellow" }
              ListElement { text: "Apple"; color: "Green" }
              ListElement { text: "Coconut"; color: "Brown" }
          }
          
          style: ComboBoxStyle {
             ...
             ...
          __dropDownStyle: MenuStyle {
              itemDelegate.label: Item {
                  height: 40
                  Row {
                      Rectangle { height: 40; width: 50; Text { anchors.centerIn: parent; text:  cbItems.get(styleData.index).text } }
                      Rectangle { height: 40; width: 50; Text { anchors.centerIn: parent; text:  cbItems.get(styleData.index).color } }
                  }
              }
          }
          

          I doubt that it can provide the same look and feel but I think its worth a try.

          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