+ Reply to Thread
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
    3,079
    Thanks
    190
    Thanked 484 Times in 475 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    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.
    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
    3,079
    Thanks
    190
    Thanked 484 Times in 475 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    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.
    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.

+ Reply to Thread

Similar Threads

  1. QWidgetAction resize in QMenu
    By stburton in forum Qt Programming
    Replies: 5
    Last Post: 10th February 2017, 07:38
  2. Replies: 2
    Last Post: 1st August 2011, 06:30
  3. Replies: 3
    Last Post: 7th April 2011, 11:09
  4. QToolBar, QWidgetAction, QWidget
    By prof.ebral in forum Newbie
    Replies: 3
    Last Post: 18th February 2010, 19:38
  5. QWidgetAction: A QTreeWidget in a QMenu
    By chezifresh in forum Qt Programming
    Replies: 1
    Last Post: 16th October 2009, 03: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