Combobox with multiple column
-
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!
-
Hmmm.... Maybe I can use ListView. What is the best way to show it in popup?
-
Hi,
Create CustomComboBox Inherit QComboBox.
Reimplemented showPopup() method.void CustomComboBox::showPopup() { //create/populate QTableWidget //set windowflags //calculate position and size //and show() tablewidget :-) }
-
Hi @jimcad
AFAIK you can try by usingComboBoxStyle
. 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.