Results 1 to 5 of 5

Thread: Application Crashes when Text Label widgets are accessed in different threads..why??

  1. #1
    Join Date
    Sep 2015
    Posts
    23
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Application Crashes when Text Label widgets are accessed in different threads..why??

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Application Crashes when Text Label widgets are accessed in different threads..wh

    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,
    _

  3. #3
    Join Date
    Sep 2015
    Posts
    23
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Application Crashes when Text Label widgets are accessed in different threads..wh

    Quote Originally Posted by anda_skoa View Post
    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

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Application Crashes when Text Label widgets are accessed in different threads..wh

    Quote Originally Posted by ganapathi View Post
    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.

    Quote Originally Posted by ganapathi View Post
    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,
    _

  5. #5
    Join Date
    Sep 2015
    Posts
    23
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Application Crashes when Text Label widgets are accessed in different threads..wh

    Yaa i found the solution.

    implement signals and slots from threads

Similar Threads

  1. How to wrap text in a label?
    By sasi in forum Qt Programming
    Replies: 5
    Last Post: 22nd October 2016, 04:14
  2. QT Object created in a private cannot be accessed
    By aquanaut in forum General Programming
    Replies: 13
    Last Post: 5th March 2015, 10:01
  3. Replies: 6
    Last Post: 22nd March 2010, 08:57
  4. how to append text in label
    By wagmare in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2009, 11:06
  5. Designer crashes when selecting some widgets
    By gwendal in forum Qt Tools
    Replies: 4
    Last Post: 21st July 2006, 13:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.