PDA

View Full Version : QListWidgetItem - context menu



QT8seven
14th December 2011, 03:42
I have successfully created a context-menu for my QListWidget. However, what I want is a context-menu per item. Now, I can check the selected item and change the context-menu based on this, but, what I really need is to know the active item. I want a standard menu as well as a item-specific menu. So, if the user right-clicks on the QListWidget one menu appears, but if they right-click on a specific item instead, that item's menu appears. How would I go about this?

Added after 8 minutes:

Figured this one out:

QListWidgetItem* temp = itemAt(point);
if(temp != NULL)

When using itemAt with a QListWidgetItem you can determine the item at the cursor position. If NULL is returned then no item was specifically clicked. This gives you the active item rather than the selected.