Am 23.01.2014 um 03:15 schrieb Eric Feigenson <e...@feigenson.net>:

>> ....  I know that on the Mac, all GUI things need to happen in the main 
>> thread,

AKA "GUI thread". We'll come to that in a moment...


>> so that the QApplication would have to run in the main thread.  But if I do 
>> a QApplication.exec() on the main thread, then the main thread will block 
>> until all the Qt goodness has completed.
> 
> Right now I'm using a dylib, but a static link would be just as good if it 
> would help.

First off, whether your code to be run is located in a shared lib or everything 
is statically linked together into a single executable does not matter for the 
problem at hand.

(There are other implications when statically compiling the Qt libs, but they 
relate to the "Qt plugin system")

> The forum posting shows some attempts at using QThreads to solve the problem, 
> but at the moment they don't, and I'm at a loss.

I don't know what that code looks like, but when it sais that "all painting 
needs to be done in the main thread" what is really meant is that "all painting 
needs to be done in the same thread where the (underlying) "painting system" 
has been initialised".

That initialisation happens when instantiating QApplication. Since for an 
ordinary Qt that typically happens in the function main() that thread is 
usually called "main thread".

However "GUI thread" is a more correct term, since - AFAIK - the instance of 
QApplication does not necessarily have to "live" in the "main thread": you 
should be able to instantiate a new thread and instantiate QApplication in that 
thread. If you restrict all your (Qt) painting to that same thread everything 
should be fine. Hence "painting in the /GUI/ thread only" is a better 
description (but again: in most Qt cases main = GUI thread).

By the way, all the above is true for all Qt supported platforms, because the 
underlying graphics systems might not like to be called from different threads 
- Cocoa is indeed one of them.


Cheers,
  Oliver

P.S. The tricky part is probably to make sure that QApplication is really only 
instantiated in the context of the new "GUI thread". Also refer to ongoing 
discussion on this mailing list about QThread and QObject::moveToThread or 
google for "you are all doing it wrong qthread" (or not ;))
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to