void MainWindow::actionEvent(QActionEvent *event){ QAction *action = event->action(); QObject *obj = sender(); if (qobject_cast<QPushButton*>(obj)) { if (event->type() == QEvent::ButtonPress) { switch(event->type()) { case QEvent::ActionChanged: setChangeAction(action); break; case QEvent::ActionAdded: connect(action, SIGNAL(triggered()), this, SLOT(triggeredAct())); break; default: ; } return; }} void MainWindow::setChangeAction(QAction *action){ addAction(action); reg->setText(action->iconText()); reg->setIcon(action->icon());}void MainWindow::triggeredAct(){ if(QAction *action = qobject_cast<QAction*>(reg)) emit triggered(action); действие… }