grantbj74
10th August 2009, 05:13
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
grantbj74
10th August 2009, 05:43
Yeah I worked it out:
//////////////////
// Setup menu bar.
//////////////////
QAction *menuAction;
QActionGroup *menuActionGroup = new QActionGroup(this);
QMenuBar *menuBar = new QMenuBar(this);
QMenu *menu = menuBar->addMenu("File");
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()));
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.