PDA

View Full Version : TreeView question



hasmik
22nd July 2009, 11:54
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);
}


Do I need reimplement MainWindow::contextMenuEvent and depends on selected item type create context menu.

Please, give me any advice.
Thanks in advance.