View Full Version : QComboBox hide top item from list

21st May 2013, 09:33

I have a problem with Qt Combobox.
I have added three item in comboBox : "Show" , "View", "Download"
Here "Show" is the permanently visible item for combobox even if i click on "View" or "Download".
But the problem is whenever popup of combobox comes it shows all three items i dont know how to hide the "Show" option in my list.
Please any idea about that?

21st May 2013, 10:00
Assuming that you want to remove/hide "Show" on some event, you have to do the following -

removeItem(int index); // for removing
insertItem(int index, QString item);// for inserting back
//index is 0 for first item

21st May 2013, 10:15
Thanks for your quick reply but i have done it via

QMenu* showToolMenu = new QMenu(ui->button_Show);
showToolMenu->addAction("View", this, SLOT(on_button_file_Download_clicked()));
showToolMenu->addAction("Download", this, SLOT(on_button_file_View_clicked()));

but now i got stucked in a problem.
when i run this code, there is an arrow icon visible on button.
please let me know how to remove arrow icon from button.

21st May 2013, 10:19
That arrow suggests that the button has a menu, nothing else. It's an indication to the user that on press of the button, a pop-up menu will be showed.

21st May 2013, 10:45
If you want get rid of the arrow (assuming you have QToolButton) you can call:

ui->button_Show->setPopupMode (QToolButton::InstantPopup)
Although be aware that

In this mode, the button's own action is not triggered.

21st May 2013, 11:01
ui->button_Show->setPopupMode (QToolButton::InstantPopup)

i have used the above code but still i am unable to remove that arrow icon.

i know that arrow indicates that button has a menu, n=but i want to remove that icon.

Added after 8 minutes:

i just missd that

QPushButton#evilButton::menu-indicator {
image: none;

above code works for me