Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

New Developer
Posts: 7
Registered: ‎01-28-2011
My Device: BB10
My Carrier: Developer

How to update UI in own QThread

QThread* thread = new QThread();
    Worker* worker = new Worker();
    // Give QThread ownership of Worker Object
    // Connect worker error signal to this errorHandler SLOT.
//        connect(worker, SIGNAL(error(QString)), this, SLOT(errorHandler(QString)));
    // Connects the thread’s started() signal to the process() slot in the worker, causing it to start.

    connect(worker, SIGNAL(finished(bb::cascades::Image)), this, SLOT(updateImage(bb::cascades::Image)));
    connect(thread, SIGNAL(started()), worker, SLOT(process()));
    // Connect worker finished signal to trigger thread quit, then delete.
    connect(worker, SIGNAL(finished()), thread, SLOT(quit()));
    connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
    // Make sure the thread object is deleted after execution has finished.
    connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));


show this:

ApplicationPrivate::context: ERROR called from non-UI thread QThread(0x8281d40)
ApplicationPrivate::context: Method called from non-UI thread

Posts: 16,897
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to update UI in own QThread

sending signals to another thread should work.

as a sidenote: Check QtConcurrent::run, it is much easier to handle than QThread in most instances.
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter