How to create Pop up menu in Qt
-
Take a look on "Menus Example":http://qt-project.org/doc/qt-5/qtwidgets-mainwindows-menus-example.html
Does it work for you ?
-
Maybe this "link":http://qt-project.org/search?search=QTableView+contextmenu will help you.
-
Thanks.That was really hepful.
@void Connection::customMenuRequested(QPoint pos)
{
//Context Menu CreationQModelIndex index=ui->tableView_2->indexAt(pos);
QModelIndex index1=ui->tableView->indexAt(pos);
QModelIndex index2=ui->tableView_3->indexAt(pos);QMenu *menu=new QMenu(this); menu->addAction(QString("Copy"), this,SLOT(slotCopy())); menu->addAction(QString("Cut"), this,SLOT(slotCut())); menu->addAction(QString("Paste"),this,SLOT(slotPaste())); menu->addAction(QString("Select"),this,SLOT(slotSelect())); menu->addAction(QString("Close"), this,SLOT(slotClose()));
menu->popup(ui->tableView_2->viewport()->mapToGlobal(pos));
menu->popup(ui->tableView->viewport()->mapToGlobal(pos));
menu->popup(ui->tableView_3->viewport()->mapToGlobal(pos));}
void Connection::slotClose()// Context Menu Option for Close
{
this->close();
}
@
When i was right click the tablview the context menu will be displayed and also working the close menu option. But i dn't knw how to write the code for cut,copy,paste, select. I searched in Google. But couldn’t find any examples out there.