Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Access violation error in QtConcurrent updating QLabel
Forum Updated to NodeBB v4.3 + New Features

Access violation error in QtConcurrent updating QLabel

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    azadsagar
    wrote on last edited by
    #1

    hello i have this 'access violation reading..." error in QtConcurrent thread when am i terminating my application. My thread is updating some status in QLabel. it seems like when i exit my application QLabel object is being destroyed and my thread is working on it. how can i resolve it ? here is my source

    @
    void Sparsh::connectCam()
    {
    QString str[]={"Connecting.","Connecting..","Connecting..."};
    unsigned int i=1;

    while(!mycam.Connect(FIRST_AVAILABLE))
    {
    if(ui.lblStatus) // i tried this but no help :(
    ui.lblStatus->setText(str[i%3]);

    Sleep(1000);
    i++;
    }

    camconnected=true;

    ui.lblStatus->setText("Device Connected...!");

    }

    @

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      Qt's GUI classes are not thread-safe. You can only update them in the main thread.

      If you want to trigger an update from a secondary thread, your secondary thread must invoke a slot in the main thread to update your QLabel.

      • Use "QMetaObject::invokeMethod()":http://qt-project.org/doc/qt-5/qmetaobject.html#invokeMethod with a Queued Connection, OR
      • Emit a signal to invoke the slot.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved