PDA

View Full Version : Application Crashes when Text Label widgets are accessed in different threads..why??



ganapathi
8th September 2015, 13:36
Hi

I have MainWindow object instantiated(On Stack) in main.cpp and also 2 threads for 2 cameras(realtime) putting their images on TextLabel widgets(which are in MainWindow).

I access text labels widgets from the threads by passing pointer of MainWindow to those threads(in constructor).

Ex: mw->ui->label_2->setPixMap(...images...);

I have no problem displaying while one thread is active. But when two threads are created , The application crashes.

Hope someone helps.

what is the best GUI architecture for displaying from multiple cameras at a time?

Regards

anda_skoa
8th September 2015, 14:09
Rule of thumb: don't ever access UI objects from any other thread than the main thread.

There is a QVideoPlayer widget which should be able to display data from a QCamera object.

Cheers,
_

ganapathi
8th September 2015, 18:20
Rule of thumb: don't ever access UI objects from any other thread than the main thread.

There is a QVideoPlayer widget which should be able to display data from a QCamera object.

Cheers,
_

Hi Anda_skoa

Thanks ....relief came when I knew there is a better way to accessing GUI from other threads.

Then what is the best way to access UI objects from other threads?

It will be very helpful if you guide me towards few resources.

Regards

anda_skoa
8th September 2015, 19:27
Thanks ....relief came when I knew there is a better way to accessing GUI from other threads.

There is no such thing, no idea where you got that from.


Then what is the best way to access UI objects from other threads?

I am repeating myself: the best and only way is to not do it.

Cheers,
_

ganapathi
9th September 2015, 19:06
Yaa i found the solution.

implement signals and slots from threads