By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,081 Members | 1,885 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,081 IT Pros & Developers. It's quick & easy.

qt ver. 3, linux, windows, and modal forms

P: n/a
Hi,

I'm having a problem with modal forms on windows. I've written a very
short test program, with a main window and a form called from the main
window. The form is set to modal with form.setModal(1) before calling
form.show().

All works as expected on Linux. The form is modal, not allowing the main
window to received the focus. If I call the form from within itself, the
topmost form is modal, and not of the previous forms will receive the
focus until the topmost form is closed; then the next topmost is modal,
and so on.

However, on Windows XP Pro (at work - don't use windows at home), the
form is not modal. The main window will receive the focus with a mouse
click even though the modal form is still on top.

The source code is identical on both OS's.

Has anyone run into this before? Is there a fix? I haven't been able to
find anything with google searches, and Trolltech's forums don't seem to
have any entries addressing the problem, either.

I have a progam that I'm writing for work using Qt and Python, which was
like pulling teeth with our Microsoft oriented IT department, and I very
much do not want to tell them that it's not going to work (modal forms
are essential).

Thanks for your help,
Mike
Mar 24 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Saturday 24 March 2007 23:08, Mike wrote:
I'm having a problem with modal forms on windows. I've written a very
short test program, with a main window and a form called from the main
window. The form is set to modal with form.setModal(1) before calling
form.show().
Is form an instance of a QWidget subclass or a QDialog subclass?

Have you tried calling form.exec_loop() instead of form.show()?
All works as expected on Linux. The form is modal, not allowing the main
window to received the focus. If I call the form from within itself, the
topmost form is modal, and not of the previous forms will receive the
focus until the topmost form is closed; then the next topmost is modal,
and so on.
This sounds like the desired behaviour.
However, on Windows XP Pro (at work - don't use windows at home), the
form is not modal. The main window will receive the focus with a mouse
click even though the modal form is still on top.
But this should show the same behaviour. I suspect that the use of show()
rather than exec_loop() leads to the platform-specific behaviour you are
seeing.
The source code is identical on both OS's.

Has anyone run into this before? Is there a fix? I haven't been able to
find anything with google searches, and Trolltech's forums don't seem to
have any entries addressing the problem, either.

I have a progam that I'm writing for work using Qt and Python, which was
like pulling teeth with our Microsoft oriented IT department, and I very
much do not want to tell them that it's not going to work (modal forms
are essential).
Modal forms are quite commonplace, so they should work as you expect. If you
above advice doesn't help, you'll need to supply some more information about
the versions of Qt, PyQt, SIP and Python you are using.

David
Mar 24 '07 #2

P: n/a
Answers interspersed.

David Boddie wrote:
On Saturday 24 March 2007 23:08, Mike wrote:
>I'm having a problem with modal forms on windows. I've written a very
short test program, with a main window and a form called from the main
window. The form is set to modal with form.setModal(1) before calling
form.show().

Is form an instance of a QWidget subclass or a QDialog subclass?
QDialog
>
Have you tried calling form.exec_loop() instead of form.show()?
Yes
>
>All works as expected on Linux. The form is modal, not allowing the main
window to received the focus. If I call the form from within itself, the
topmost form is modal, and not of the previous forms will receive the
focus until the topmost form is closed; then the next topmost is modal,
and so on.

This sounds like the desired behaviour.
>However, on Windows XP Pro (at work - don't use windows at home), the
form is not modal. The main window will receive the focus with a mouse
click even though the modal form is still on top.

But this should show the same behaviour. I suspect that the use of show()
rather than exec_loop() leads to the platform-specific behaviour you are
seeing.
Tried both - didn't make any difference.
>
>The source code is identical on both OS's.

Has anyone run into this before? Is there a fix? I haven't been able to
find anything with google searches, and Trolltech's forums don't seem to
have any entries addressing the problem, either.

I have a progam that I'm writing for work using Qt and Python, which was
like pulling teeth with our Microsoft oriented IT department, and I very
much do not want to tell them that it's not going to work (modal forms
are essential).

Modal forms are quite commonplace, so they should work as you expect. If you
above advice doesn't help, you'll need to supply some more information about
the versions of Qt, PyQt, SIP and Python you are using.
I'll have to get back to you on that one. I'm at home now (weekend).
Will get versions from work and let you know.
>
David
Thanks so much,
Mike
Mar 24 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.