06-28-2012 09:32 PM - edited 06-28-2012 09:34 PM
Hi, All
I want make a custom image view that support URL source.
I start a thread to request the image data from network, then update the image view with the data, but I get the error:
ApplicationPrivate::resourceManager: ERROR called from non-UI thread QThread(0x81eeb8c)
ApplicationPrivate::resourceManager: Method called from non-UI thread
This is my code segment:
class URLImageView: public CustomControl, public QThread
{
public:
URLImageView();
private:
void run();
ImageView* mImageView;
Container* mRootContainer;
};
URLImageView::URLImageView()
{
mRootContainer = Container::create().background(Color::Gray).prefer redSize(100,100);
mImageView = ImageView::create().image(QUrl("asset:///button.pn g"));
mRootContainer->add(mImageView);
setRoot(mRootContainer);
start();
}
void URLImageView::run()
{
//get data from network
//...
//...
//create image from binary data
Image* image = new Image(pixelBuffer);
mImageView->setImage(image);
}
I know in old BB OS (Java Platform), I can get the UI event lock from Application like this:
synchronized (Application.getEventLock())
{
// I can update UI control here
}
Is there same way in BB10 Cascades, or what's the right way if I want update UI in non-ui thread ?
Thanks
Solved! Go to Solution.
06-28-2012 10:49 PM
06-29-2012 01:54 AM
Thanks Peter, your tips is very useful for me.
Resolved by using signal and slot:
Worker Thread in Qt using Signals & Slots
![]()