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?


Qt Code:
  1. build QTableWidget ......
  2. editable = true;
  3. TableMenu->setMouseTracking(false);
  4. TableMenu->setContextMenuPolicy( Qt::CustomContextMenu );
  5. connect(TableMenu, SIGNAL(itemChanged(QTableWidgetItem *)), this, SLOT(UpDateItem(QTableWidgetItem *)));
  6. connect(TableMenu, SIGNAL( customContextMenuRequested( const QPoint & ) ), this, SLOT( TableContexMenu() ) );
  7. connect(edit_modus_table, SIGNAL(toggled(bool)),this, SLOT(TableEditContex(bool)));
  8. } /* end table */
  9.  
  10. void W_Menu::TableContexMenu()
  11. {
  12. mnuContext = new QMenu();
  13. ...... other action .....
  14. mnuContext->addAction(QIcon( ":/i/img/user.png" ),tr( "Edit Item " ), this, SLOT( EditPerson() ) );
  15. ...............................
  16. mnuContext->addAction(tr( "Close this" ), mnuContext, SLOT( close() ) );
  17. mnuContext->exec( QCursor::pos() );
  18. }
  19. /* ############################################# MENU TABLE CONTEXT ################################### */
  20. void W_Menu::EditPerson()
  21. {
  22. mnuContext->clear();
  23. mnuContext->close();
  24. int IdCell = GetItemId(TableMenu->currentColumn(),TableMenu->currentRow());
  25. int personaedits = items[IdCell]->GetDBNummers();
  26. if (personaedits > 0) {
  27. emit OpenEditIdShow(personaedits);
  28. }
  29. }
To copy to clipboard, switch view to plain text mode