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. QDialog as a QMdiSubWindow: Weird behavior when minimizing

QDialog as a QMdiSubWindow: Weird behavior when minimizing

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmdiareaqmdisubwindowqdialog
2 Posts 2 Posters 251 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.
  • A Offline
    A Offline
    Alvein
    wrote on 11 Nov 2023, 03:14 last edited by Alvein 11 Nov 2023, 03:15
    #1

    Hello!

    This short program creates a QDialog as a MDI sub window.

    I've noticed that minimizing the dialog makes the QDialog::exec() event loop to finish. Which makes no sense at all.

    Anybody has an idea about how to solve this?

    Thank you very much!

    #include <QApplication>
    #include <QtWidgets>
    
    int main(int argc,char *argv[]) {
        QApplication  app(argc,argv);
        QMainWindow   win;
        QMdiArea      mdi;
        QMdiSubWindow *sub;
        QDialog       dlg;
    
        win.setCentralWidget(&mdi);
        win.show();
    
        sub=mdi.addSubWindow(&dlg);
        sub->resize(win.size()/2);
    
        qDebug() << "before dlg.exec()";
        dlg.exec();
        qDebug() << "after dlg.exec()";
    
        win.close();
        return 0;
    }
    

    I hope I'm overlooking some small detail and that the solution is simple haha

    J 1 Reply Last reply 11 Nov 2023, 07:49
    0
    • A Alvein
      11 Nov 2023, 03:14

      Hello!

      This short program creates a QDialog as a MDI sub window.

      I've noticed that minimizing the dialog makes the QDialog::exec() event loop to finish. Which makes no sense at all.

      Anybody has an idea about how to solve this?

      Thank you very much!

      #include <QApplication>
      #include <QtWidgets>
      
      int main(int argc,char *argv[]) {
          QApplication  app(argc,argv);
          QMainWindow   win;
          QMdiArea      mdi;
          QMdiSubWindow *sub;
          QDialog       dlg;
      
          win.setCentralWidget(&mdi);
          win.show();
      
          sub=mdi.addSubWindow(&dlg);
          sub->resize(win.size()/2);
      
          qDebug() << "before dlg.exec()";
          dlg.exec();
          qDebug() << "after dlg.exec()";
      
          win.close();
          return 0;
      }
      

      I hope I'm overlooking some small detail and that the solution is simple haha

      J Offline
      J Offline
      JonB
      wrote on 11 Nov 2023, 07:49 last edited by
      #2

      @Alvein
      I don't know the answer to your question. But it always surprises me why anyone would use a QDialog as anything other than what it is intended for, such as an MDI subwindow:

      A dialog window is a top-level window mostly used for short-term tasks and brief communications with the user.

      1 Reply Last reply
      3

      1/2

      11 Nov 2023, 03:14

      • Login

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