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?
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?
I don't understand. If you click outside any item then the returned pointer will be null.
found i think the answer
QModelIndex index = this->indexAt(pos);
then in the code..
if(index.isValid()) .....
You're using item based approach, so:
Qt Code:
if(item) { // item is valid }To copy to clipboard, switch view to plain text mode
Bookmarks