PDA

View Full Version : [PyQt] How to do two threads, two windows?



robtheg
13th May 2009, 08:02
Hi,

I have an application that runs out of a QMainWindow. I have an operation that needs to run in a separate thread and output text to a separate dialog. The dialog needs to be killed if the main window is exited/rejected.

It would be nice for the user if the main window and the dialog were controlled by separate threads, so heavy updates on the one window won't bog down the other.

I think I've overcomplicated my implementation, as you can see in my other post (http://www.qtcentre.org/forum/f-qt-programming-2/t-pyqt4-crash-when-writing-to-qtextedit-in-a-thread-20950.html), and I suspect I might need to do something like is found in this post (http://www.qtcentre.org/forum/f-qt-programming-2/t-accesing-qtextedit-from-thread-17462.html).

I've accepted that I don't quite understand what needs to be done and so have come to the newbie list :)

Many thanks.

zgulser
13th May 2009, 08:30
Hi
I understand you have two different QMainWindows?

if so, in order to work them together in the meaning of exiting/ rejecting, you can set your subwindow window flag.

yourSubWin-> setWindowFlag(blabla);

robtheg
13th May 2009, 08:51
Thanks for the response...

I have a main window as a QMainWindow and a dialog with a QTextEdit that is to be used for output.

Pushing a button on the main window needs to spawn a thread to run an operation and also create the dialog box, which the thread will then use for output. That dialog box has its own close button but also needs to close automatically if the main window is closed.

Hope that explains it a little better.