I see that QButtonGroups let you throw in an integer when you do buttonGroup->addButton and then you can access this via the buttonClicked signal. This is handy for identifying which of of the buttons in the group was clicked. Why isn't there something similar for QActionGroups? QActionGroups have a selected signal, which will pass you back the QAction which you can use to identify which action was clicked, but I still want an associated Id so that I can use my enum. Is there anywhere inside of QAction that I can store such an integer, without it being a hack?
Example usage:
toolsActGroup = new QActionGroup(this);
toolsActGroup->setExclusive(true);
selectToolAct = new QAction(QIcon(":/icons/custom/select.png"), tr("&Select"), toolsActGroup);
selectToolAct->setIconVisibleInMenu(false);
selectToolAct->setShortcut(Qt::Key_S);
selectToolAct->setCheckable(true);
selectToolAct->setStatusTip(tr("Select objects to modify or delete"));
selectToolAct->setProperty("tool", EditorScene::Select);
selectToolAct->setChecked(true);
// more actions here...
connect(toolsActGroup, SIGNAL(selected(QAction*)), this, SLOT(toolSelected(QAction*))); // use one signal for the whole (exclusive) action group
void EditorWindow::toolSelected(QAction* act) {
// pass the value to the widget that needs it
m_scene->setTool((EditorScene::Tool)act->property("tool").toInt());
}