class SpinBoxAction : public QWidgetAction {public: SpinBoxAction (const QString & title) : QWidgetAction (NULL) { QWidget* pWidget = new QWidget (NULL); QHBoxLayout* pLayout = new QHBoxLayout(); pLabel = new QLabel(title); pPushButton = new QPushButton("+"); pMenu = new QMenu(); pMenu->addMenu(""); pLayout->addWidget(pLabel); pLayout->addWidget(pPushButton); pLayout->addWidget(pMenu); pWidget->setLayout(pLayout); setDefaultWidget(pWidget); } }private: QMenu *pMenu; QPushButton *pPushButton; QLabel *pLabel;};
SpinBoxAction * spinBoxAction = new SpinBoxAction(tr("Action Title")); ui->menuOlolo->addAction(spinBoxAction);