126QAction *QActionGroup::addAction(QAction* a)
129 if (!d->actions.contains(a)) {
130 d->actions.append(a);
131 QObject::connect(a, &QAction::triggered,
this, &QActionGroup::_q_actionTriggered);
132 QObject::connect(a, &QAction::changed,
this, &QActionGroup::_q_actionChanged);
133 QObject::connect(a, &QAction::hovered,
this, &QActionGroup::_q_actionHovered);
135 a->d_func()->setEnabled(d->enabled,
true);
136 if (!a->d_func()->forceInvisible)
137 a->d_func()->setVisible(d->visible);
140 QActionGroup *oldGroup = a->d_func()->group;
141 if (oldGroup !=
this) {
143 oldGroup->removeAction(a);
144 a->d_func()->group =
this;
145 a->d_func()->sendDataChanged();
184void QActionGroup::removeAction(QAction *action)
187 if (d->actions.removeAll(action)) {
188 if (action == d->current)
189 d->current =
nullptr;
190 QObject::disconnect(action, &QAction::triggered,
this, &QActionGroup::_q_actionTriggered);
191 QObject::disconnect(action, &QAction::changed,
this, &QActionGroup::_q_actionChanged);
192 QObject::disconnect(action, &QAction::hovered,
this, &QActionGroup::_q_actionHovered);
193 action->d_func()->group =
nullptr;