is it necessary to use connection for frequent gui updation ??



  • I am working on a code which is used for automated dimension check on the basis of camera image...
    for each new image the gui qlable and table(containing dimension details and pass or fail result) gets updated at the rate of 400 images per minute now , i am doing these updates using setvalue and all functions ....recently i came across a forum:
    https://forum.qt.io/topic/24358/solved-qwidget-repaint-recursive-repaint-detected

    according to which not using connection is an isuue...so can some one tell me if using setvalue fuction can become a problem or not if so then please tell me how to update table content and variable values with signal and slot

    void StackedWidget_new::run_camimage()
    {
        ////////CODE FOR TRIGGERING TEST SAMPLES FOR ALL 4 CAMERAS
        int k= fr_run.size();
        FrameRec frame;
       // qDebug()<<"REACHED HERE RUN_CAM";
    
        for(int i =0;i<k;i++)
        {
    
                frame=fr_run.back();
                fr_run.pop_back();
                cv::Mat m_ConvertImage=cv::Mat(frame.Height,frame.Width,CV_8UC1);
                std::copy( frame.buff, frame.buff+frame.Height*frame.Width, m_ConvertImage.data );
               if(frame.CameraIndex==0)
               {
                   Cam1_run=m_ConvertImage;
                   cam1_run = Mat2QImage(m_ConvertImage);
                   ui->IMAGE_CAM_5->setPixmap(QPixmap::fromImage(cam1_run));
                   ui->IMAGE_CAM_9->setPixmap(QPixmap::fromImage(cam1_run));
    
               }
               else if(frame.CameraIndex==1)
               {
                    Cam2_run=m_ConvertImage;
                   cam2_run = Mat2QImage(m_ConvertImage);
                   ui->IMAGE_CAM_6->setPixmap(QPixmap::fromImage(cam2_run));
                   ui->IMAGE_CAM_10->setPixmap(QPixmap::fromImage(cam2_run));
               }
               else if(frame.CameraIndex==2)
               {
                    Cam3_run=m_ConvertImage;
                   cam3_run = Mat2QImage(m_ConvertImage);
                   ui->IMAGE_CAM_7->setPixmap(QPixmap::fromImage(cam3_run));
                   ui->IMAGE_CAM_11->setPixmap(QPixmap::fromImage(cam3_run));
               }
               else if(frame.CameraIndex==3)
               {
                   Cam4_run=m_ConvertImage;
                   cam4_run = Mat2QImage(m_ConvertImage);
                   ui->IMAGE_CAM_8->setPixmap(QPixmap::fromImage(cam4_run));
                   ui->IMAGE_CAM_12->setPixmap(QPixmap::fromImage(cam4_run));
               }
               if(fr.size()==0)
               {
                   CalibClick[2]=0;
               }
        }
        for(int i=0;i<ftr.size();i++)
        {
            switch (ftr[i]->cam_id)
            {
            case 1:
    
                ui->tableWidget_2->item(ftr[i]->index,4)->setText(QString::number(ftr[i]->inpix));
                ui->tableWidget_2->item(ftr[i]->index,5)->setText(QString::number(ftr[i]->inmm));
    
               if(ftr[i]->decision==1)
                        ui->tableWidget_2->item(ftr[i]->index,6)->setText("PASS");
                else
                        ui->tableWidget_2->item(ftr[i]->index,6)->setText("FAIL");
    
                break;
    
            case 2:
                ui->tableWidget_6->item(ftr[i]->index,4)->setText(QString::number(ftr[i]->inpix));
                ui->tableWidget_6->item(ftr[i]->index,5)->setText(QString::number(ftr[i]->inmm));
                        if(ftr[i]->decision==1)
                                ui->tableWidget_6->item(ftr[i]->index,6)->setText("PASS");
                        else
                                ui->tableWidget_6->item(ftr[i]->index,6)->setText("FAIL");
                break;
            case 3:
                ui->tableWidget_7->item(ftr[i]->index,4)->setText(QString::number(ftr[i]->inpix));
                ui->tableWidget_7->item(ftr[i]->index,5)->setText(QString::number(ftr[i]->inmm));
                        if(ftr[i]->decision==1)
                                ui->tableWidget_7->item(ftr[i]->index,6)->setText("PASS");
                        else
                                ui->tableWidget_7->item(ftr[i]->index,6)->setText("FAIL");
                break;
            case 4:
                ui->tableWidget_8->item(ftr[i]->index,4)->setText(QString::number(ftr[i]->inpix));
                ui->tableWidget_8->item(ftr[i]->index,5)->setText(QString::number(ftr[i]->inmm));
                        if(ftr[i]->decision==1)
                                ui->tableWidget_8->item(ftr[i]->index,6)->setText("PASS");
                        else
                                ui->tableWidget_8->item(ftr[i]->index,6)->setText("FAIL");
                break;
    
            }
        }
    
    
    }
    

    this is how i am updating table and qlabel right now


  • Qt Champions 2016

    Hi
    it will only be a problem if you make too long lasting loop.
    Then it will stop redrawing.


Log in to reply
 

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