Results 1 to 2 of 2

Thread: Modal QDialog inside QMdiArea

  1. #1
    Join Date
    May 2008
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Modal QDialog inside QMdiArea

    Hi

    I am trying to use modal (Qt::WindowModal) QDialog inside QMdiArea and it doesn't work.
    Here is example code:
    Qt Code:
    1. #include <QApplication>
    2. #include <QtGui>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7. QMainWindow mainWin;
    8.  
    9. QMdiArea* area = new QMdiArea();
    10. mainWin.setCentralWidget(area);
    11.  
    12. //window 1
    13. QWidget* w = new QWidget();
    14. w->setWindowTitle("w");
    15.  
    16. QVBoxLayout* layout = new QVBoxLayout();
    17. layout->addWidget(new QLineEdit());
    18. layout->addWidget(new QTextEdit());
    19. layout->addWidget(new QPushButton("B1"));
    20. w->setLayout(layout);
    21.  
    22. area->addSubWindow(w);
    23.  
    24. //window 2
    25. QWidget* w2 = new QWidget();
    26. w2->setWindowTitle("w2");
    27.  
    28. QVBoxLayout* layout2 = new QVBoxLayout();
    29. layout2->addWidget(new QLineEdit());
    30. layout2->addWidget(new QTextEdit());
    31. layout2->addWidget(new QPushButton("B2"));
    32. w2->setLayout(layout2);
    33.  
    34. QMdiSubWindow* sw2 = area->addSubWindow(w2);
    35.  
    36. mainWin.show();
    37.  
    38. //dialog
    39. QDialog d(sw2);// block window 2
    40. d.setWindowTitle("d");
    41. d.setWindowModality(Qt::WindowModal);
    42.  
    43. QVBoxLayout* layout3 = new QVBoxLayout();
    44. layout3->addWidget(new QLineEdit());
    45. layout3->addWidget(new QLineEdit());
    46. layout3->addWidget(new QPushButton("B3"));
    47. d.setLayout(layout3);
    48.  
    49. area->addSubWindow(&d);
    50. d.exec();
    51.  
    52. return app.exec();
    53. }
    To copy to clipboard, switch view to plain text mode 

    Dialog should block window 2, but it deasn't block anything. It looks like ordinary window.

    What is the correct way to do this?

    Thank you.

  2. #2
    Join Date
    Jan 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Modal QDialog inside QMdiArea

    I'm also trying to do something like that.

    I want to have a number of QMdiArea tabs, and in every of them - modal window stack.

    It's not working probably because QMdiSubWindow handles all the stuff and it's not modal dialog by origin...

Similar Threads

  1. Replies: 7
    Last Post: 25th July 2016, 14:42
  2. QTreeWidget row updates inside QDialog
    By innerhippy in forum Qt Programming
    Replies: 4
    Last Post: 19th December 2008, 18:32
  3. QDialog inside QWizardPage
    By baray98 in forum Qt Programming
    Replies: 1
    Last Post: 9th May 2008, 07:28

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.