qmenu actions don't show



  • I created a class that derives from QMenu, and have the constructor call the QMenu constructor with no parent, i.e. QMenu("Title"). Then inside the derived class I add actions to the menu, by calling addAction("Action title") a view times. Then an instance of this class is added to the menu bar in my main window:

    menu->setParent(mainWindow); addMenu(&menu)

    Expected: result: the menu shows with all the actions.
    Actual result: only the menu title shows, but no actions.
    Interestingly if I don't reparent, the actions do show up.

    However: the menu is created from within a separate plugin. When I don't reparent, the application crashes upon exit, apparently because by default the application object is the parent of the menu instead of the menu bar. The crash happens because the module is unloaded before the QApplication object is destructed, and because only then the menu gets destructed, it tries to call a destructor that is not available anymore (because it resides in the plugin)

    How do I fix this?


  • Lifetime Qt Champion

    Hi,

    Your design reminds me of the Plug & Paint example and its friends. You should take a look at them to see if you can grab something to fix your issue.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.