Results 1 to 2 of 2

Thread: Qmenu Stable close on QTableWidget

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Qmenu Stable close on QTableWidget

    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 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qmenu Stable close on QTableWidget

    Please provide a minimal compilable example which reproduces the problem.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.