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