PDA

View Full Version : Qmenu Stable close on QTableWidget



patrik08
12th July 2006, 03:42
I have on mainwindow a QWorkspace 2 QDockWidget and at on QDockWidget i build a QTableWidget + Qt::CustomContextMenu if the action have only one emit to mainwindow this qmenu stay open 2 or moore left click .... on same table row...
How i can close this qmenu just to beginn by next right click?




build QTableWidget ......
editable = true;
TableMenu->setMouseTracking(false);
TableMenu->setContextMenuPolicy( Qt::CustomContextMenu );
connect(TableMenu, SIGNAL(itemChanged(QTableWidgetItem *)), this, SLOT(UpDateItem(QTableWidgetItem *)));
connect(TableMenu, SIGNAL( customContextMenuRequested( const QPoint & ) ), this, SLOT( TableContexMenu() ) );
connect(edit_modus_table, SIGNAL(toggled(bool)),this, SLOT(TableEditContex(bool)));
} /* end table */

void W_Menu::TableContexMenu()
{
mnuContext = new QMenu();
...... other action .....
mnuContext->addAction(QIcon( ":/i/img/user.png" ),tr( "Edit Item " ), this, SLOT( EditPerson() ) );
...............................
mnuContext->addAction(tr( "Close this" ), mnuContext, SLOT( close() ) );
mnuContext->exec( QCursor::pos() );
}
/* ############################################# MENU TABLE CONTEXT ################################### */
void W_Menu::EditPerson()
{
mnuContext->clear();
mnuContext->close();
int IdCell = GetItemId(TableMenu->currentColumn(),TableMenu->currentRow());
int personaedits = items[IdCell]->GetDBNummers();
if (personaedits > 0) {
emit OpenEditIdShow(personaedits);
}
}

wysota
17th July 2006, 11:03
Please provide a minimal compilable example which reproduces the problem.