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

David Boddie david at boddie.org.uk
Sat Mar 24 19:20:42 EDT 2007


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



More information about the Python-list mailing list