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.
Code:
def __init__(self, text, parent=None):
super(Oper_Comnt, self).__init__(parent)
self.__index = 0
self.setupUi(self)
self.setModal(True)
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.
Re: Dialog Modality - Tutorial Needed
Quote:
Originally Posted by
Michael Druckenmiller Sr
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.
Quote:
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().
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,
Re: Dialog Modality - Tutorial Needed
Quote:
Originally Posted by
Michael Druckenmiller Sr
So, if I am using parent=None, application modal "should" block eveything else until the dialog is closed. correct?
Yes.
Quote:
But, would setting parent=mainWindow allow Window Modal to work as well?
Yes, and that's a correct approach.
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. :)
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.