PDA

View Full Version : QActionGroup issue



sajis997
17th February 2012, 15:18
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:



H3DMainWindow::H3DMainWindow(QWidget *parent):
QMainWindow(parent)
{
setupUi(this);

configureActions();
configureMenus();
}

H3DMainWindow::~H3DMainWindow()
{

}

void H3DMainWindow::configureActions()
{
m_actionEXAMINE = new QAction(tr("EXAMINE"),this);
m_actionEXAMINE->setChecked(true);

m_actionFLY = new QAction(tr("FLY"),this);

m_actionWALK = new QAction(tr("WALK"),this);

m_actionLOOKAT = new QAction(tr("LOOKAT"),this);

m_actionNONE = new QAction(tr("NONE"),this);


//create the action group and add the actions to the group
m_navigationGroup = new QActionGroup(this);
m_navigationGroup->addAction(m_actionEXAMINE);
m_navigationGroup->addAction(m_actionFLY);
m_navigationGroup->addAction(m_actionWALK);
m_navigationGroup->addAction(m_actionLOOKAT);
m_navigationGroup->addAction(m_actionNONE);
}

void H3DMainWindow::configureMenus()
{
//configure the navigation menu
menu_Navigation->addAction(m_actionEXAMINE);
menu_Navigation->addAction(m_actionFLY);
menu_Navigation->addAction(m_actionWALK);
menu_Navigation->addAction(m_actionLOOKAT);
menu_Navigation->addAction(m_actionNONE);
menu_Navigation->addSeparator();
}


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


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

norobro
17th February 2012, 22:36
From the docs under QAction::setChecked() (http://doc.qt.nokia.com/4.7-snapshot/qaction.html#checked-prop)]:
Only checkable actions can be checked.
See QAction::setCheckable() (http://doc.qt.nokia.com/4.7-snapshot/qaction.html#checkable-prop)