Just wondering how to add a QActionGroup to a QMenuBar?
I know how to add a QAction, just can't find how to add a QActionGroup.
You need to setup the QActionGroup before its added, right?
Thanks in advance
Brendan
Printable View
Just wondering how to add a QActionGroup to a QMenuBar?
I know how to add a QAction, just can't find how to add a QActionGroup.
You need to setup the QActionGroup before its added, right?
Thanks in advance
Brendan
Yeah I worked it out:
Code:
////////////////// // Setup menu bar. ////////////////// QAction *menuAction; menuAction = menu->addAction("Load"); connect(menuAction, SIGNAL(triggered()), this, SLOT(Load_Configuration())); menuAction = menu->addAction("Save"); connect(menuAction, SIGNAL(triggered()), this, SLOT(Save_Configuration())); menuActionGroup->setExclusive(true); menu = menuBar->addMenu("ComPort"); menuAction = menu->addAction("No Port"); menuAction->setChecked(true); menuAction->setCheckable(true); menuActionGroup->addAction(menuAction); connect(menuAction, SIGNAL(triggered()), this, SLOT(Select_ComPort0())); menuAction = menu->addAction("Com 1"); menuAction->setCheckable(true); menuActionGroup->addAction(menuAction); connect(menuAction, SIGNAL(triggered()), this, SLOT(Select_ComPort1())); menuAction = menu->addAction("Com 2"); menuAction->setCheckable(true); menuActionGroup->addAction(menuAction); connect(menuAction, SIGNAL(triggered()), this, SLOT(Select_ComPort2()));