Hello.
I want to create popup menu on QListWidgets, so I create this:
listWidgets->setContextMenuPolicy(Qt::CustomContextMenu);
connect(listWidgets,
SIGNAL(customContextMenuRequested
(QPoint)),
this,
SLOT(popupMenu
(QPoint)));
listWidgets->setContextMenuPolicy(Qt::CustomContextMenu);
connect(listWidgets, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(popupMenu(QPoint)));
To copy to clipboard, switch view to plain text mode
and slot popupMenu:
void MainWindow
::popupMenu(QPoint point
) {
popupMenu->addAction("blabla");
popupMenu->popup(point);
}
void MainWindow::popupMenu(QPoint point) {
QMenu *popupMenu = new QMenu();
popupMenu->addAction("blabla");
popupMenu->popup(point);
}
To copy to clipboard, switch view to plain text mode
All is ok because menu has been shown when I click right mouse button but not there where it should, it shows outside window application.
How can I fix it? How to create popup menu where I click?
Bookmarks