PDA

View Full Version : Modal dialog in QMainWindow's event() function



tanminh
21st June 2007, 22:18
Hi,

My problem is: the CPU runs high (~60 %) when I display a modal dialog inside QMainWindow's event() function.

I don't reimplement event() but it gets called as a result of cross-thread signal/slot.
Essentially, my application takes requests from the network, then modifies the GUI accordingly. The application queues the requests in a separate thread. As each request is dequeued a signal is sent and the application processes the request. The signal/slot connection looks like the following:

connect
(
thread,
thread_request_ready_signal,
gui_thread_app,
gui_thread_app_request_processing_slot
)

CPU usage is fine until one of the request needs to pop up a modal dialog, say, to report an error in processing the request. This is where the CPU usage leaps to ~60% from a normal <5%. I think this is because the event() function is prevented from proceeding until the user clears the modal dialog.

Would someone please explain and tell me how to fix this problem? Or, in general, if a worker thread needs to report an error in a modal dialog how should it do that? For my application, a modeless dialog approach is not desirable.

Thanks

EDIT: "...until one of the request needs to pop up a modal dialog..." should read "...until the request processing slot needs to pop up a modal dialog..."

high_flyer
22nd June 2007, 09:46
in general, only the GUI (main) thread should do GUI stuff.
Have the worker thread raise a flag on which the dialog will be launched in the GUI thread.