[Solved] QMenu item/action pre selection
-
a context menu is build up of QMenu items, which essentially are buttons.
You can use the cursor keys, but it sounds odd to 'pre-select' something. Its not a selectable thing.What you may be thinking of is that you position the menu such that the item you want is under the cursor. And this you can do yourself, you just use the QPoint you pass when popping up the menu. Calculate the offset to your wanted item (based on the height of the buttons), and subtract that from the popup position.
-
Thanks Thomas,
For the current requirement the contextMenu is associated with a pushButton i.e the position of the context menu is fixed, The button hold some property which is listed in the contextMenu, So when the contextMenu is displayed the current property of the pushButton is shown as selected in the menu, the user can change the property by selecting other items from the same.
I have another implementation where I am using a listWidget that shows all properties and is added using QWidgetAction to the contextMenu. This implementation works as required, so i think i'll stick to this as of now.
Regards,
Soumitra