PDA

View Full Version : context menu for table



sattu
10th January 2011, 07:24
hi everyone,
I create a context menu for a dialog .It is working fine.But my problem is to restrict within the table view.



QMenu menu(this);
menu.addAction(deleteAct);
menu.exec(event->globalPos());



Here i am using globalpos() .but i dont know what to use to restrict it.

plz gvie some soln.

high_flyer
10th January 2011, 09:24
Have a look at QWidget::mapFromGlobal().

sattu
10th January 2011, 10:09
thanks for reply.
Actually i got the answer.
ie.


item = new QAction(QIcon("icon_image.png"), "Item Name", this);
connect(item, SIGNAL(triggered()), this, SLOT(on_actionTaken_clicked()));
this->ui->tableView->addAction(item);
this->ui->tableView->setContextMenuPolicy(Qt::ActionsContextMenu);