PDA

View Full Version : qtablewidget popupmenu



totosugito
6th February 2008, 04:52
Dear,
I have a qtablewidget. I want to add popupmenu when user right mouse click in item on qtablewidget.
this is my script :

void QTTapeUtil::on_tblWidgetInput_mousePressEvent( QMouseEvent * event )
{
int brs1 = tblWidgetInput->currentRow();
QTableWidgetItem *texktnya = tblWidgetInput->item(brs1,0);
if (texktnya)
{
if ( event->button() == Qt::RightButton )
{
QMenu menu(this);
menu.addAction(coba1);
menu.addAction(coba2);
menu.exec();
}
}
}
popupmenu show if item in tablewidget not empty. I try to use this script but I can not see popupmenu in my tablewidget. what wrong in my code? can you give me and example about popupmenu with tabelwidget (maybe copy paste operation)

thank for your attention

regardly

toto

aamer4yu
6th February 2008, 05:51
Did you try QWidget::contextMenuEvent
It might be of help to you