Hello,
I've created main window. The central widget of main window is TreeView (see attached picture). I want to do the following: if user does right click on the item then context menu appears. Context menu's content depends on the type of the item. But when user does right click outside the item context menu doesn't appeard.
To appear context menu I've written the following.
void MainWindow::createContextMenu()
{
tree->addAction(newLibAction);
tree->addAction(openLibAction);
tree->addAction(closeLibAction);
tree->setContextMenuPolicy(Qt::ActionsContextMenu);
}
void MainWindow::createContextMenu()
{
tree->addAction(newLibAction);
tree->addAction(openLibAction);
tree->addAction(closeLibAction);
tree->setContextMenuPolicy(Qt::ActionsContextMenu);
}
To copy to clipboard, switch view to plain text mode
Do I need reimplement MainWindow::contextMenuEvent and depends on selected item type create context menu.
Please, give me any advice.
Thanks in advance.
Bookmarks