Results 1 to 6 of 6

Thread: Problem with QDialog modality

  1. #1
    Join Date
    Sep 2014
    Posts
    18
    Thanks
    2
    Qt products
    Platforms
    Unix/X11 Windows

    Question Problem with QDialog modality

    Hi everyone!
    I want to create a child widget with option to block parent widget.
    Lot of people advise to create QDialog with exec_ method and it's cool.
    I even tried to set setWindowModality(QtCore.Qt.ApplicationModal)
    As result the child widget is always on top of parent, but if I click on parent the child loses his focus.
    And the parent widget still can be moved on screen or even minimized in trey.
    What's the point of such modality if it's not block parent absolutely?
    My Qt - 4.8

  2. #2
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QDialog modality

    Below 2 cases are working fine for me. 4.8 & windows.



    Qt Code:
    1. #include "mainwindow.h"
    2. #include <QApplication>
    3. #include <QDialog>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8. MainWindow w;
    9. w.show();
    10.  
    11. QDialog* dai = new QDialog;
    12.  
    13.  
    14. //You can use either of this
    15. 1. dai->setModal(true)
    16. 2. dai->setWindowModality(Qt::ApplicationModal);
    17.  
    18.  
    19. dai->show();
    20.  
    21.  
    22. return a.exec();
    23. }
    To copy to clipboard, switch view to plain text mode 
    Thanks :-)

  3. The following user says thank you to prasad_N for this useful post:

    Goodwin (31st August 2015)

  4. #3
    Join Date
    Sep 2014
    Posts
    18
    Thanks
    2
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QDialog modality

    Thanks man,
    ((( Your code exactly what I'm doing.

    It's so funny I cannot close parent widget, but I still can minimize it and make it fullscreen or move on screen.
    I don't understand what is wrong?

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QDialog modality

    None of these are interactions with the window's content or, depending on the platform, even with the window itself, but the window decoration provided by the windowing system.

    It is more like paint events also still being processed in the parent (so it can update itself properly) despite a modal child window.

    Cheers,
    _

  6. #5
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QDialog modality

    Quote Originally Posted by anda_skoa View Post
    None of these are interactions with the window's content or, depending on the platform, even with the window itself, but the window decoration provided by the windowing system.

    It is more like paint events also still being processed in the parent (so it can update itself properly) despite a modal child window.

    Cheers,
    _
    Little messy, But when we set Modality for child window, parent should not get minimized or maximized right ??
    Thanks :-)

  7. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QDialog modality

    Quote Originally Posted by prasad_N View Post
    Little messy, But when we set Modality for child window, parent should not get minimized or maximized right ??
    Modality prevents the parent window or application (depending on the mode) from receiving user events, such as key presses or mouse events.
    Resize events (like paint events or timer events) are generated by the system, thus are not affected by modality.

    Cheers,
    _

  8. The following user says thank you to anda_skoa for this useful post:

    prasad_N (31st August 2015)

Similar Threads

  1. Dialog Modality - Tutorial Needed
    By Michael Druckenmiller Sr in forum Newbie
    Replies: 5
    Last Post: 13th October 2011, 19:39
  2. workaround for messagebox modality bug
    By mortoray in forum Qt Programming
    Replies: 1
    Last Post: 17th October 2010, 11:07
  3. Problem with QDialog
    By sudheer168 in forum Qt Programming
    Replies: 2
    Last Post: 2nd December 2009, 12:26
  4. Window Modality question
    By zgulser in forum Qt Programming
    Replies: 11
    Last Post: 25th May 2009, 11:44
  5. mainwindow modality
    By user in forum Qt Programming
    Replies: 0
    Last Post: 11th July 2008, 00:54

Tags for this Thread

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.