Access violation error in QtConcurrent updating QLabel



  • 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...!");

    }

    @


  • Moderators

    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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.