Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt minimizing Dialog minimizes Parent Window

Qt minimizing Dialog minimizes Parent Window

Scheduled Pinned Locked Moved General and Desktop
qt5.4dialogwindow
3 Posts 2 Posters 4.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    haris123
    wrote on 27 Jun 2015, 06:18 last edited by
    #1

    In my application I have a parent window and over it a child dialog, when I minimize my child dialog parent window also get minimized, how can I avoid it. The child dialog is sub-classed from QDialog

    And the child dialog pop-up is executed in this way,

    ChildDilago PopUp;
    PopUp.setModal(false);
    Qt::WindowFlags flags = Qt::Window | Qt::WindowSystemMenuHint
                                | Qt::WindowMinimizeButtonHint
                                | Qt::WindowCloseButtonHint;
    PopUp.setWindowFlags(flags);
    PopUp.setUI(data);
    PopUp.exec();
    

    What can be the issue here?, any help will be appreciated...

    Thanks
    Haris

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 27 Jun 2015, 13:32 last edited by Chris Kawa
      #2

      There are two things here that mix into the issue:

      First, as described in the docs, exec() always shows the dialog as modal and ignores anything you set with setModal().

      Second, the Qt::Window flag makes the widget a normal window, so when it is shown modally it is treated as main app window and thus minimizing it minimizes whole app.

      One thing you can do is remove the call to setModal(false), as it does nothing anyway, and change your flags to contain Qt::Dialog instead of Qt::Window. The dialog will now be (well, obviously) a dialog and not minimize the whole app. The downside is that, since it is modal, the OS will send the main window to the back, as there is no interaction with it possible anyway.

      If you want a proper, non-modal dialog that can be minimized independently of your main window you can do it like this:

              ChildDilago * PopUp = new ChildDilago (this); //so that it won't go out of scope and be destroyed, modality is false by default
              PopUp->setAttribute(Qt::WA_DeleteOnClose, true); //so that it will be deleted when closed
              Qt::WindowFlags flags = Qt::Dialog | Qt::WindowSystemMenuHint
                                          | Qt::WindowMinimizeButtonHint
                                          | Qt::WindowCloseButtonHint;
              PopUp->setWindowFlags(flags); //so that it has min/max frame buttons
              PopUp->setUI(data);
              PopUp->show(); // so that it is shown not modally
      
      1 Reply Last reply
      0
      • H Offline
        H Offline
        haris123
        wrote on 27 Jun 2015, 18:05 last edited by
        #3

        Hi Thanks for the detailed answer, now the issue solved

        1 Reply Last reply
        0

        2/3

        27 Jun 2015, 13:32

        • Login

        • Login or register to search.
        2 out of 3
        • First post
          2/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved