// Qt::DefaultContextMenu
{
if (item)
{
// an item exists under the requested position
// ...
menu.exec(event->globalPos());
}
else
{
// there is no item under the requested position
}
}
// Qt::DefaultContextMenu
void MyTreeWidget::contextMenuEvent(QContextMenuEvent* event)
{
QTreeWidgetItem* item = itemAt(event->pos());
if (item)
{
// an item exists under the requested position
QMenu menu(this);
// ...
menu.exec(event->globalPos());
}
else
{
// there is no item under the requested position
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks