Results 1 to 4 of 4

Thread: setitemchecked on QMenu

  1. #1
    Join Date
    May 2008
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default setitemchecked on QMenu

    hello,
    i'v got one sample code and finished to build and it works fine now.
    this code is used on qt3 library, but my working is on qt4.
    so i tried to port my all codes from qt3 to qt4, rebuild it and result is ok.
    i added menu for change my app theme, checking for menuitem isnt working.
    i mean proper menuitem is always checking when im clicking it.
    here is source code.
    Qt Code:
    1. tools = new Q3PopupMenu( this, "toolsMenu" );
    2.  
    3. styleThemes = new Q3PopupMenu( this, "StyleThemes" );
    4. id2007 = styleThemes->insertItem( tr("Office 2007"), this, SLOT(setOffice2007()) );
    5. id2003 = styleThemes->insertItem( tr("Office 2003"), this, SLOT(setOffice2003()) );
    6. styleThemes->setCheckable( TRUE );
    7. styleThemes->setItemChecked(id2007, true);
    8. styleThemes->setItemChecked(id2003, false);
    9.  
    10. tools->insertItem( QIcon( QPixmap(QString(IMAGE_PATH)+"menuIcons/styletheme.png") ),
    11. tr("Themes"), styleThemes );
    To copy to clipboard, switch view to plain text mode 

    can you give me any suggestion for this issue?
    thx.
    Last edited by jpn; 2nd June 2008 at 11:27. Reason: changed [quote] to [code] tags

  2. #2
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    12

    Default Re: setitemchecked on QMenu

    First of all, if you are porting to QT4, why are you still using the Q3PopupMenu class (instead of just QMenu)? Then you can just do setChecked() on the QAction item instead (but you'd have to use addAction() instead of insertItem()).

    i mean proper menuitem is always checking when im clicking it.
    I'm not exactly sure what you mean by this... When you click, the item you click gets checked? (this would be correct) Or are both functions getting called?

    Vycke

  3. #3
    Join Date
    May 2008
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: setitemchecked on QMenu

    hi, vycke
    i did try to use QMenu instead of Q3PopupMenu class, but i have a lot of code of this part.
    so i continused to use this class(Q3PopupMenu).
    I'm not exactly sure what you mean by this... When you click, the item you click gets checked? (this would be correct) Or are both functions getting called?
    this screenshot help your understand.
    Attached Images Attached Images

  4. #4
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    12

    Default Re: setitemchecked on QMenu

    If you mean that both are always checked, I'm not sure how to solve that (except maybe use a QActionGroup).. If you mean that when you check one the other stays checked, the QActionGroup would solve that -- or you can do it programmatically in the slots (i.e. uncheck the one you didn't click).

    I hope this helps, if not, maybe one of the experts here can help.

    Vycke

Similar Threads

  1. Caption in QMenu
    By Lykurg in forum Newbie
    Replies: 4
    Last Post: 16th April 2014, 22:41
  2. QMenu and signals
    By mattia in forum Newbie
    Replies: 6
    Last Post: 20th December 2007, 09:09
  3. how to popup and close a QMenu
    By Placido Currò in forum Qt Programming
    Replies: 15
    Last Post: 14th May 2007, 16:41
  4. Qmenu Stable close on QTableWidget
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 17th July 2006, 10:03
  5. Replies: 2
    Last Post: 23rd February 2006, 16:38

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
  •  
Qt is a trademark of The Qt Company.