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

M

Mike

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
 
D

David Boddie

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
 
M

Mike

Answers interspersed.

David said:
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

This sounds like the desired behaviour.


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.
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.

Thanks so much,
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top