Results 1 to 4 of 4

Thread: QWidgetAction doesn't allow app to quit

  1. #1
    Join Date
    Apr 2017
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QWidgetAction doesn't allow app to quit

    I created a menu in my QMainWindow derived class, and added a QWidget to it via QWidgetAction. Now my app does not close and stays in infinite loop when I try to close it. Any hints on why this happens?

    Here's the code:

    MainWindow* parent = ...;
    auto menu = parent->menuBar()->addMenu("Menu");
    auto action = new QWidgetAction(menu);
    auto widget = new QLabel("Lol");
    action->setDefaultWidget(widget);
    menu->addAction(action);


    This happens under OSX Sierra, Qt 5.8

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QWidgetAction doesn't allow app to quit

    Considering you haven't told us anything about where this code actually gets executed, and what happens inside the "..." of the first line, it's pretty much impossible to say what the error is.

    My guess is that in the first line you are creating a new MainWindow instance (and different from the one you create in main()), so you end up with an app that has multiple instances of MainWindow running at the same time.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Apr 2017
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QWidgetAction doesn't allow app to quit

    I simply created a QMainWindow application on QtCreator and ran it with that code for creating the menu with the widget.

    On Ubuntu Linux, nothing is rendered. Under OSX, it creates an infinite loop when I try to close the app

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QWidgetAction doesn't allow app to quit

    I'll say it again:

    Considering you haven't told us anything about where this code actually gets executed, and what happens inside the "..." of the first line, it's pretty much impossible to say what the error is.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. QWidgetAction resize in QMenu
    By stburton in forum Qt Programming
    Replies: 7
    Last Post: 11th January 2018, 15:27
  2. Replies: 2
    Last Post: 1st August 2011, 07:30
  3. Replies: 3
    Last Post: 7th April 2011, 12:09
  4. QToolBar, QWidgetAction, QWidget
    By prof.ebral in forum Newbie
    Replies: 3
    Last Post: 18th February 2010, 20:38
  5. QWidgetAction: A QTreeWidget in a QMenu
    By chezifresh in forum Qt Programming
    Replies: 1
    Last Post: 16th October 2009, 04:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.