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

Combobox with multiple column

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 1.6k 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 14 Oct 2015, 06:39 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 16 Oct 2015, 18:51 last edited by
      #2

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

      P 1 Reply Last reply 17 Oct 2015, 09:13
      0
      • R Offline
        R Offline
        ReinaldoJr
        wrote on 16 Oct 2015, 19:27 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
          16 Oct 2015, 18:51

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

          P Offline
          P Offline
          p3c0
          Moderators
          wrote on 17 Oct 2015, 09:13 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

          1/4

          14 Oct 2015, 06:39

          • Login

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