On 06/08/2014 12:10 PM, igor.mironc...@gmail.com wrote:
> 
> QCoreApplication app( argc, argv );
> 
> Object o;
> QThread t;
> o.moveToThread( &t );
> t.start();
> 
> QTimer::singleShot( 0, &o, SLOT( start() ) );
> 

Hi Igor,

why are you using a QTimer? As far as I know, you could invoke the slot
directly.

QMetaObject::invokeMethod(&o, "start", Qt::QueuedConnection);

This will place an event in the threads event loop. This works in
several places in my project. Maybe there is a better solution.
In principle you can also omit Qt::QueuedConnection.

QMetaObject::invokeMethod(&o, "start");

Default is Qt::AutoConnection, which detects o is running in a different
thread. But I usually pass QueuedConnection explicitly.

Roland



_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to