How to add context menu in a QCombo box
-
I am using a QCombo box to display a list of items,for each item i want a context menu i.e.,on each item of the list, if we right click it should show "Delete" item.
What is the best possible way to do it?
Thanks
-
Set "contextMenuPolicy":http://qt-project.org/doc/qt-4.8/qwidget.html#contextMenuPolicy-prop for combo box to Qt::CustomContextMenu and connect "customContextMenuRequested":http://qt-project.org/doc/qt-4.8/qwidget.html#customContextMenuRequested to your slot. In this slot you can call "QMenu::exec":http://qt-project.org/doc/qt-4.8/qmenu.html#exec-2 with point passed in slot function
-
I did the same way but then the context menu comes only for the first item in the list and when i click on the drop down list the context menu does not comes for each and every item in the list