Reputation: 55
I'm implementing something similar to Eclipse's Package Explorer, using QTreeWidget
, but I don't know how to handle right mouse button clicks.
How do I use Qt creator so I can handle right clicks on a QTreeWidgetItem
?
Upvotes: 1
Views: 675
Reputation: 1533
You can set the context menu policy on the tree view item and then create a signal/slot event handlers as per usual.
For an example you can refer to this:
ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->treeView, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(onCustomContextMenu(const QPoint &)));
Then just implement the onContextMenu function above
Upvotes: 3