How to detect theright clicked item when using customContextMenuRequested signal
hello all
quick question
im using in Treewidget the customContextMenuRequested signal and using using popup with qmenu
How can I get the item pointer / object / reference that just bean right clicked before the pop up executed
I need to make some validation on the item
Re: How to detect theright clicked item when using customContextMenuRequested signal
QTreeWidget::itemAt() returns a pointer to an item in a specific point relative to the widget's top-left corner. Remember the widget is probably the view's viewport and not the view itself.
Re: How to detect theright clicked item when using customContextMenuRequested signal
one problem remains when i right click not on tree node i still trigger the customContextMenuRequested SLOT function , how can i check there is its QTreeWidgetItem object?
Re: How to detect theright clicked item when using customContextMenuRequested signal
I don't understand. If you click outside any item then the returned pointer will be null.
Re: How to detect theright clicked item when using customContextMenuRequested signal
found i think the answer
QModelIndex index = this->indexAt(pos);
then in the code..
if(index.isValid()) .....
Re: How to detect theright clicked item when using customContextMenuRequested signal
You're using item based approach, so:
Code:
if(item) {
// item is valid
}