Right click on the view, nothing happens, here's the code:
Code:
{ viewMenu->setContextMenuPolicy(Qt::CustomContextMenu); viewMenu->addAction("Edit"); viewMenu->popup(pos); }
viewMenu is declared as a slot.
so, what have I done wrong?
Printable View
Right click on the view, nothing happens, here's the code:
Code:
{ viewMenu->setContextMenuPolicy(Qt::CustomContextMenu); viewMenu->addAction("Edit"); viewMenu->popup(pos); }
viewMenu is declared as a slot.
so, what have I done wrong?
This function must be called before emitting signal (customContextMenuRequested).Quote:
setContextMenuPolicy(Qt::CustomContextMenu);
eg:
and the pos must be translated form widget coordinates to screen coordinates.more information in Qt document,Please look forQuote:
view = new QTableView();
view->setContextMenuPolicy(Qt::CustomContextMenu);
connect(view, SIGNAL(customContextMenuRequested ( const QPoint &)), this, SLOT(viewMenu(const QPoint &)));
.Quote:
customContextMenuRequested