Yeah, I've already tried that stuff, and this is what I've got:
Here is code:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
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;
};
|
Calling:
|
Source code
|
1
2
|
SpinBoxAction * spinBoxAction = new SpinBoxAction(tr("Action Title"));
ui->menuOlolo->addAction(spinBoxAction);
|
This is not that result what I'm expecting, new menu item should look like native but extended, and in my case I have no icon space, and menu has a border. And, of course, button is
near menu, not built in.