PDA

View Full Version : creating widgets asynchronously



tampstaffs
23rd February 2009, 08:55
Hi,

My aim is to create widgets asynchronously.
I tried using QFutureWatcher for doing this,but its complaining widgets should be created in same gui thread.Is there any way to do this

jogeshwarakundi
23rd February 2009, 09:29
you could emit a signal with required parameters from your worker thread and write a slot in the gui thread which actually creates the widgets.

tampstaffs
23rd February 2009, 10:26
HI,

I was getting this kind of warnings and errors

QPixmap: It is not safe to use pixmaps outside the GUI thread

ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file kernel\qwidget.cpp, line 1050

jogeshwarakundi
23rd February 2009, 10:30
yes,
I believe you are creating the widgets in the context of your worker thread. that is not allowed in Qt. All UI elements should be created only within the main GUI thread. so make such changes accordingly. like suggested previously, emit a signal from the worker thread and create the GUI elements in the main thread slot.

cheers!