Results 1 to 2 of 2

Thread: QActionGroup issue

  1. #1
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default QActionGroup issue

    Hello forum,


    I have just recently updated the qt to 4.8.

    I have some .ui file from the previous version and i am continuing working on it. I am trying to crate a simple QActionGroup to the menu as follows:

    Qt Code:
    1. H3DMainWindow::H3DMainWindow(QWidget *parent):
    2. QMainWindow(parent)
    3. {
    4. setupUi(this);
    5.  
    6. configureActions();
    7. configureMenus();
    8. }
    9.  
    10. H3DMainWindow::~H3DMainWindow()
    11. {
    12.  
    13. }
    14.  
    15. void H3DMainWindow::configureActions()
    16. {
    17. m_actionEXAMINE = new QAction(tr("EXAMINE"),this);
    18. m_actionEXAMINE->setChecked(true);
    19.  
    20. m_actionFLY = new QAction(tr("FLY"),this);
    21.  
    22. m_actionWALK = new QAction(tr("WALK"),this);
    23.  
    24. m_actionLOOKAT = new QAction(tr("LOOKAT"),this);
    25.  
    26. m_actionNONE = new QAction(tr("NONE"),this);
    27.  
    28.  
    29. //create the action group and add the actions to the group
    30. m_navigationGroup = new QActionGroup(this);
    31. m_navigationGroup->addAction(m_actionEXAMINE);
    32. m_navigationGroup->addAction(m_actionFLY);
    33. m_navigationGroup->addAction(m_actionWALK);
    34. m_navigationGroup->addAction(m_actionLOOKAT);
    35. m_navigationGroup->addAction(m_actionNONE);
    36. }
    37.  
    38. void H3DMainWindow::configureMenus()
    39. {
    40. //configure the navigation menu
    41. menu_Navigation->addAction(m_actionEXAMINE);
    42. menu_Navigation->addAction(m_actionFLY);
    43. menu_Navigation->addAction(m_actionWALK);
    44. menu_Navigation->addAction(m_actionLOOKAT);
    45. menu_Navigation->addAction(m_actionNONE);
    46. menu_Navigation->addSeparator();
    47. }
    To copy to clipboard, switch view to plain text mode 

    But the action group is not working. I am supposed have radio button beside each of the actions, it shows something like this
    Radio.jpg


    As you can see in the attached image there is a menu called navigation and several items are added to the menu, But i am not getting the radio buttom beside each of them.


    What am i missing ?


    Regards
    Sajjad

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QActionGroup issue

    From the docs under QAction::setChecked()]:
    Only checkable actions can be checked.
    See QAction::setCheckable()

Similar Threads

  1. Qt Designer QActionGroup from Qt Designer
    By sajis997 in forum Qt Tools
    Replies: 0
    Last Post: 15th February 2012, 12:53
  2. QActionGroup allowing unchecking ?
    By divide in forum Qt Programming
    Replies: 0
    Last Post: 29th June 2010, 14:16
  3. How do you add a QActionGroup to a QMenuBar?
    By grantbj74 in forum Newbie
    Replies: 1
    Last Post: 10th August 2009, 05:43
  4. How to create QActionGroup through Qt Designer
    By kalos80 in forum Qt Tools
    Replies: 1
    Last Post: 26th June 2009, 19:06
  5. QActionGroup question
    By maverick_pol in forum Qt Programming
    Replies: 7
    Last Post: 6th October 2007, 18:34

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.