Results 1 to 6 of 6

Thread: Dialog Modality - Tutorial Needed

  1. #1
    Join Date
    Sep 2011
    Posts
    21
    Qt products
    Platforms
    Unix/X11 Windows

    Default Dialog Modality - Tutorial Needed

    I am using pyQT 4.8.5 with Python 2.7.2 with no add-ins. GPL versions.
    At this time I am developing on Windows Xp SP3 and my code also runs on Windows 7. I need to maintain cross-platform capability to include Linux.

    I am not clear on setting up True Modal with my Dialogs.

    In QT Designer it gives three choices:
    Non-Modal
    Window Modal
    Application Modal

    I am not sure what the difference is between Window Modal and Application Modal?

    (I would appreciate an explanation of what each actually does or sets up.)

    I know exec_ will place the Dialog in its GUI Loop (for want of a better term)

    The problem I am having, is that, while everything appears to "freeze" until the dialog closes I can still click on my Main Form and have yet another Dialog Pop-Up.

    This is NOT what I want.

    I *think* my problem is in my constructor, which I am borrowing from "Rapid GUI Programming with Python and QT" by Mark Summerfield.


    Qt Code:
    1. def __init__(self, text, parent=None):
    2. super(Oper_Comnt, self).__init__(parent)
    3. self.__index = 0
    4. self.setupUi(self)
    5. self.setModal(True)
    To copy to clipboard, switch view to plain text mode 

    I note that my parent=None.

    I suspect that I need to make my parent equal to my main form?

    If this is so where do I get the information to make parent equal to my main form?

    And, which Modal Property setting should I be using?

    Thanks

    Mike Sr.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Dialog Modality - Tutorial Needed

    Quote Originally Posted by Michael Druckenmiller Sr View Post
    I am not sure what the difference is between Window Modal and Application Modal?
    WindowModal blocks the parent window of the modal dialog, ApplicationModal blocks all top-level windows of the application.

    The problem I am having, is that, while everything appears to "freeze" until the dialog closes I can still click on my Main Form and have yet another Dialog Pop-Up.
    Then use ApplicationModal and call exec().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2011
    Posts
    21
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: Dialog Modality - Tutorial Needed

    So, if I am using parent=None, application modal "should" block eveything else until the dialog is closed. correct?

    But, would setting parent=mainWindow allow Window Modal to work as well?

    I had two of my dialogs set to Window Modal they are now set to Application Modal.

    Thanks,

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Dialog Modality - Tutorial Needed

    Quote Originally Posted by Michael Druckenmiller Sr View Post
    So, if I am using parent=None, application modal "should" block eveything else until the dialog is closed. correct?
    Yes.

    But, would setting parent=mainWindow allow Window Modal to work as well?
    Yes, and that's a correct approach.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Sep 2011
    Posts
    21
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: Dialog Modality - Tutorial Needed

    Great...



    Now all I need to do is *LEARN* what value to use to identify my Main Window.

    (You do know that VB-6 isn't ~really~ an OO language, right?

    And. !please! don't tell me I need to use an hwnd (in Windows)!

    Time to experiment... What's the worst that could happen? Seeing that I do make frequent backups.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Dialog Modality - Tutorial Needed

    I'm not sure what the problem is. Usually you create dialogs from within code belonging to other widgets or objects that have a handle (like a pointer in c++) to the widget so it's just a matter of passing it to the dialog's constructor. If you can't get such handle then you can use QApplication::topLevelWindows() to query for all application windows.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. workaround for messagebox modality bug
    By mortoray in forum Qt Programming
    Replies: 1
    Last Post: 17th October 2010, 11:07
  2. closing child dialog closes parent dialog
    By sparticus_37 in forum Newbie
    Replies: 2
    Last Post: 28th May 2010, 19:46
  3. Window Modality question
    By zgulser in forum Qt Programming
    Replies: 11
    Last Post: 25th May 2009, 11:44
  4. mainwindow modality
    By user in forum Qt Programming
    Replies: 0
    Last Post: 11th July 2008, 00:54
  5. Basic Qt4 tutorial needed
    By pthomas in forum Qt Programming
    Replies: 26
    Last Post: 16th October 2006, 15:11

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.