QComboBox hide top item from list
Hello,
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?
Re: QComboBox hide top item from list
Assuming that you want to remove/hide "Show" on some event, you have to do the following -
Code:
removeItem(int index); // for removing
insertItem
(int index,
QString item
);
// for inserting back//index is 0 for first item
Re: QComboBox hide top item from list
Thanks for your quick reply but i have done it via
Code:
showToolMenu->addAction("View", this, SLOT(on_button_file_Download_clicked()));
showToolMenu->addAction("Download", this, SLOT(on_button_file_View_clicked()));
ui->button_Show->setMenu(showToolMenu);
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.
Re: QComboBox hide top item from list
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.
Re: QComboBox hide top item from list
If you want get rid of the arrow (assuming you have QToolButton) you can call:
Code:
ui
->button_Show
->setPopupMode
(QToolButton::InstantPopup)
Although be aware that
Quote:
In this mode, the button's own action is not triggered.
http://qt-project.org/doc/qt-4.8/qto...popupMode-prop
Re: QComboBox hide top item from list
Code:
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:
ahhhhh
i just missd that
above code works for me