Xandareva
24th July 2010, 11:09
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)));
and slot popupMenu:
void MainWindow::popupMenu(QPoint point) {
QMenu *popupMenu = new QMenu();
popupMenu->addAction("blabla");
popupMenu->popup(point);
}
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?
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)));
and slot popupMenu:
void MainWindow::popupMenu(QPoint point) {
QMenu *popupMenu = new QMenu();
popupMenu->addAction("blabla");
popupMenu->popup(point);
}
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?