My goal is to make menu with labeled separators. So, I am running this code:
QMenu *menu = new QMenu;
QAction *group1 = menu->addSeparator();
group1->setText("Group of actions #1");
menu->addAction("Action #1");
menu->addAction("Action #2");
menu->addAction("Action #3");
QAction *group2 = menu->addSeparator();
group2->setText("Group of actions #2");
menu->addAction("Action #1");
menu->addAction("Action #2");
menu->addAction("Action #3");
QToolButton btn;
btn.setText("Click me");
btn.setMenu(menu);
btn.setPopupMode(QToolButton::InstantPopup);
btn.show();
and got this
instead of this (I created it by MS Paint :) )
What's wrong?
EDIT: Yes, there are another question like this (Non interactive items in QMenu), but maybe more simplier way exists?
One of solutions is using "Fusion" theme :) I just added code below into int main
function:
int main(int argc, char *argv[]) {
QApplication::setStyle("Fusion");
QApplication a(argc, argv);
...
addSection(const QString &)
might work. – PhospholipideaddSection
displays only line too. read comments just now there. The problem is OS-specific (Win 7). Well, thank you for help! What to do with question now? – Joliejoliet