0

I have a program which creates QMenu and adds QMenu to first menu. The program runs perfectly on qt4, but when I compile it with qt5, the submenu does not appear. Here is an example code:

QMenu *menu = this->menuBar()->addMenu("Menu");
QMenu *menu2 = menu->addMenu("Menu2");
QAction *act = menu2->addAction("act");

QSystemTrayIcon *qsti = new QSystemTrayIcon(this);
qsti->setContextMenu(menu);
qsti->show();

Menubar shows everything correctly but systemtrayicon fails to show submenu. Secreenshots: menubar systemtray

Here, you can see that there is no submenu in the second picture(systemtray). Is there any workaround to solve this issue? I'm on Ubuntu 15.04 with Qt 5.4.1.

isamert
  • 482
  • 4
  • 12

1 Answers1

0

Step forward is:

QMenu *menu = this->menuBar()->addMenu("Menu");
QMenu *menu2 = new QMenu("Menu2", menu);
QAction *act = menu2->addAction("act");
menu->addMenu(menu2);

QSystemTrayIcon *icon = new QSystemTrayIcon(this);
icon->setContextMenu(menu);
icon->show();

Now it shows that there is action but on my Ubuntu it is displayed with some kind of bug. Can you try it?

Alexander Tyapkov
  • 4,837
  • 5
  • 39
  • 65
  • I tried but nothing changed. Again, menubar shows correctly but QSystemTrayIcon doesnt show the action. I think it's qt5 related bug but I am not sure, maybe some things changed after qt5. If you have windows, can you try if it works? – isamert Aug 13 '15 at 19:11
  • In my case the behavior has changed a bit. With you example nothing is shown, with my I can see an arrow on the menu and after clicking I see long line which should be an action. Sorry, I can test it only under Ubuntu. – Alexander Tyapkov Aug 13 '15 at 19:16
  • Thanks for your response. Your qt version could be different, that can be the cause of your examples behavior on your computer. The result is same on my computer with these two examples. Apart from that, this seems like real bug. – isamert Aug 13 '15 at 19:28
  • I am using Qt 5.5. Try to report it as a bug, probably later they will solve it. – Alexander Tyapkov Aug 13 '15 at 19:35