[Qt-interest] Create a new GUI Thread

Andreas Pakulat apaku at gmx.de
Mon Mar 9 23:29:51 CET 2009


On 09.03.09 16:41:41, Luke Campagnola wrote:
> On Mon, Mar 2, 2009 at 18:56, David Johnson <david at usermode.org> wrote:
> 
> > The GUI parts of the application need to be in the same thread. It's a
> > limitation on both X11 and Mac. There may be ways around this under
> > Windows,
> > but it is not supported and may break with new Qt releases.
> 
> I thought that might be the case, but I'm pretty surprised by it--why should
> X11 care whether two windows are controlled by two separate processes or by
> two threads in the same process?

Because two processes have two completely separate memory areas which they
control, however two threads in the same process have both access to the
same memory and hence you can easily get into trouble when both access the
same data. In particular all kinds of X11 window-data, pixmaps etc. are in
that memory and (IIRC) all X11 operations are completely thread-unsafe.
 
> But since QThreads can easily communicate with each other, there is very
> > rarely a need for GUI elements to be in different threads. Have a worker
> > thread do the heavy lifting, then communicate its results to the main GUI
> > thread.
> 
> In my case, the majority of the heavy lifting is in GUI operations (ie
> graphicsview updates--multiple scrolling plots and video displays).

Did you try to profile your GUI ops and check which parts take most of the
time? If this is Qt code maybe you should talk to QtSoftware about these
problems.

Oh and try out Qt4.5, everybody's saying it has lots of
gui-speed-improvements (though I didn't notice anything myself)

Andreas

-- 
It was all so different before everything changed.



More information about the Qt-interest-old mailing list