Bonjour,
Comment dois je faire pour obtenir pour chaque item de mon treewidget "xbelTree" un menu contextuel approprié.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 xbelTree->setContextMenuPolicy(Qt::CustomContextMenu); connect(xbelTree, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowTreeContextMenu(const QPoint&)));Merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 void ManagementConsoleView::ShowTreeContextMenu(const QPoint& pnt) { QList<QAction *> actions; if (xbelTree->indexAt(pnt).isValid()) { actions.append(ui.actionActivate); actions.append(ui.actionDeactivate); } if (actions.count() > 0) QMenu::exec(actions, xbelTree->mapToGlobal(pnt)); }
Partager