0
votes
QComboBox *comboBox = new QComboBox(this);
comboBox->addItems(QStringList() << "item1" << "item2");
ui->treeWidget->setItemWidget(item, 1, comboBox);

I have used the method like the above code to add the comboBox to some itemWidget in a QtreeWidget. The appearance is not very good when the comboBox always shows.

Is there a method to hide the comboBox and it would appear again when I click that cell? Please give me some help. Thanks.

My current result: enter image description here

1
You could show a picture of what you get.eyllanesc
I have added a picture. ThanksNg Clement
What is it you do not like about the result?eyllanesc
i want to hide the border and the dropDown image before I click that cell. That means those cell would be same as the other cells in general and the comboBox would popup after I clicked that cell. Is it possible to do it?Ng Clement
You can do that with item delegates. An item delegate displays static content, and when an edit is triggered, replaces it with an editor widget.king_nak

1 Answers

0
votes

you can use css

QComboBox{ border:none; } 
QComboBox::down-arrow {image: url(:images/img/blank.png) }
QComboBox::drop-down { background-color:transparent }

http://doc.qt.io/archives/qt-4.8/stylesheet-examples.html#customizing-qcombobox