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. Time delay in loading progress bar (GIF Format)
Forum Updated to NodeBB v4.3 + New Features

Time delay in loading progress bar (GIF Format)

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 3 Posters 1.5k Views
  • 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.
  • sankarapandiyanS sankarapandiyan

    @jsulm Is there is any way to free the event loop and execute this code as the way by itself without thread . Because i am using GIF Format only thats why i am asking .

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by JonB
    #7

    @sankarapandiyan
    I was going to say same as @jsulm. But in any case, is it safe to use processEvents() inside a slot? Won't that potentially mess things up?

    I don't know what your code is doing or what " Because i am using GIF Format only" signifies. If you really don't want to do thread, if you do not want to wait till the code is finished inside the pushbutton slot (I don't know if you do), you might be able to use a QTimer() to avoid thread....?

    1 Reply Last reply
    1
    • sankarapandiyanS sankarapandiyan

      @jsulm Is there is any way to free the event loop and execute this code as the way by itself without thread . Because i am using GIF Format only thats why i am asking .

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #8

      @sankarapandiyan There is an easy way to move some work into another thread: https://doc.qt.io/qt-5/qtconcurrentrun.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • jsulmJ jsulm

        @sankarapandiyan There is a dirty workaround: calling https://doc.qt.io/qt-5/qcoreapplication.html#processEvents inside on_pushButton_4_clicked() as often as possible. But it is really this: dirty workaround.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #9

        @jsulm
        I don't want to sully this discussion, but could you just give a quick "yes" or "no" to my

        But in any case, is it safe to use processEvents() inside a slot? Won't that potentially mess things up?

        e.g. can't user press button a second time while in slot for first time and cause havoc?

        jsulmJ 1 Reply Last reply
        1
        • JonBJ JonB

          @jsulm
          I don't want to sully this discussion, but could you just give a quick "yes" or "no" to my

          But in any case, is it safe to use processEvents() inside a slot? Won't that potentially mess things up?

          e.g. can't user press button a second time while in slot for first time and cause havoc?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #10

          @JonB said in Time delay in loading progress bar (GIF Format):

          e.g. can't user press button a second time while in slot for first time and cause havoc?

          I guess he/she can :-)
          But same applies to using thread: you have to make sure you don't trigger the same action when it is already being executed. Not hard to implement (disconnect the slot or use a guard variable).

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          5
          • sankarapandiyanS Offline
            sankarapandiyanS Offline
            sankarapandiyan
            wrote on last edited by
            #11

            @jsulm @JonB I have used process event( ), And i get a output what i want .. But at last both the progress bar gif windows and task windows are closed automatically .Here i want to hide a progress bar gif window at last , but here both windows are closed . So how to fix this problem .

            this is my code

            void MainWindow::on_pushButton_4_clicked()
            {
                QMovie*movie=new QMovie(":/somegif.gif");
                qDebug() << "test1";
                    if(!movie->isValid()){
                        //something went Wrong
                        return;
                    }
                    //play GIF
                    auto label=new QLabel();
                    label->resize(400,180);
                    label->setMovie(movie);
                    label->show();
                    movie->start();
            
                    QTimer*timer=new QTimer(this);
                    connect(timer,SIGNAL(timeout()),this,SLOT(PrintDebugInTimer()));
                    timer->start(1000);
                    //start time to close it after 10 sec
                    QTimer::singleShot(10000,[label,&timer]{
                       // label->close();
                        label->deleteLater();
                        timer->stop();
                    });
            
                Mat image = imread("/home/pi/test.jpg");
                //Rect myROI(445, 745, 400, 400);
                //Mat crop = image(myROI);
                //imwrite("/home/pi/1.png", crop);
                Mat roi1 = image( Rect(2000,730,400,400));
                Mat roi2 = image( Rect(1220,720,400,400));
                Mat roi3 = image( Rect(445,745,400,400));
                imwrite("/home/pi/1.png", roi1);
                imwrite("/home/pi/2.png", roi2);
                imwrite("/home/pi/3.png", roi3);
            
                digitalWrite(7,LOW);
                digitalWrite(5,HIGH);
            
                for(int i=0;i<(35*50);i++)
                {
                    QCoreApplication::processEvents();
            
                    digitalWrite(4,1);
                    //delay(0.5);//for milliseconds
                    usleep(250);//for micro seconds
                    digitalWrite(4,0);
                    //delay(0.5);//for milliseconds
                    usleep(250);//for micro seconds
                }
                digitalWrite(7,HIGH);
                popMessageBox();
                Mat image1 = imread("/home/pi/test.jpg");
                Mat roi4 = image1( Rect(2000,730,400,400));
                Mat roi5 = image1( Rect(1220,720,400,400));
                Mat roi6 = image1( Rect(445,745,400,400));
                imwrite("/home/pi/4.png", roi4);
                imwrite("/home/pi/5.png", roi5);
                imwrite("/home/pi/6.png", roi6);
                digitalWrite(7,LOW);
                digitalWrite(5,HIGH);
            
                for(int i=0;i<(34*50);i++)
                {
                    QCoreApplication::processEvents();
            
                    digitalWrite(4,1);
                    //delay(0.5);//for milliseconds
                    usleep(250);//for micro seconds
                    digitalWrite(4,0);
                    //delay(0.5);//for milliseconds
                    usleep(250);//for micro seconds
                }
                digitalWrite(7,HIGH);
                popMessageBox();
                Mat image2 = imread("/home/pi/test.jpg");
                Mat roi7 = image2( Rect(2000,730,400,400));
                Mat roi8 = image2( Rect(1220,720,400,400));
                Mat roi9 = image2( Rect(445,745,400,400));
                imwrite("/home/pi/7.png", roi7);
                imwrite("/home/pi/8.png", roi8);
                imwrite("/home/pi/9.png", roi9);
                digitalWrite(7,LOW);
                digitalWrite(5,HIGH);
            
                for(int i=0;i<(34*50);i++)
                {
                    QCoreApplication::processEvents();
            
                    digitalWrite(4,1);
                    //delay(0.5);//for milliseconds
                    usleep(250);//for micro seconds
                    digitalWrite(4,0);
                    //delay(0.5);//for milliseconds
                    usleep(250);//for micro seconds
                }
                digitalWrite(7,HIGH);
                popMessageBox();
                Mat image3 = imread("/home/pi/test.jpg");
                Mat roi10 = image3( Rect(2000,730,400,400));
                Mat roi11 = image3( Rect(1220,720,400,400));
                imwrite("/home/pi/10.png", roi10);
                imwrite("/home/pi/11.png", roi11);
            
                QPixmap pix1,pix2,pix3,pix4,pix5,pix6,pix7,pix8,pix9,pix10,pix11;
                pix1.load("/home/pi/11.png");
                pix2.load("/home/pi/10.png");
                pix3.load("/home/pi/9.png");
                pix4.load("/home/pi/8.png");
                pix5.load("/home/pi/7.png");
                pix6.load("/home/pi/6.png");
                pix7.load("/home/pi/5.png");
                pix8.load("/home/pi/4.png");
                pix9.load("/home/pi/3.png");
                pix10.load("/home/pi/2.png");
                pix11.load("/home/pi/1.png");
                pix1 = pix1.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                pix2 = pix2.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                pix3 = pix3.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                pix4 = pix4.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                pix5 = pix5.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                pix6 = pix6.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                pix7 = pix7.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                pix8 = pix8.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                pix9 = pix9.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                pix10 = pix10.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
            
            
            
                ui->label_3->setPixmap(pix1);
                ui->label_4->setPixmap(pix2);
                ui->label_5->setPixmap(pix3);
                ui->label_6->setPixmap(pix4);
                ui->label_7->setPixmap(pix5);
                ui->label_8->setPixmap(pix6);
                ui->label_9->setPixmap(pix7);
                ui->label_10->setPixmap(pix8);
                ui->label_11->setPixmap(pix9);
                ui->label_12->setPixmap(pix10);
                ui->label_13->setPixmap(pix11);
                Scalar meanValue;
                meanValue = mean(roi1);
                
                qDebug()<<meanValue[0];
                qDebug()<<meanValue[1];
                qDebug()<<meanValue[2];
            
            
            }
            
            jsulmJ 1 Reply Last reply
            0
            • sankarapandiyanS sankarapandiyan

              @jsulm @JonB I have used process event( ), And i get a output what i want .. But at last both the progress bar gif windows and task windows are closed automatically .Here i want to hide a progress bar gif window at last , but here both windows are closed . So how to fix this problem .

              this is my code

              void MainWindow::on_pushButton_4_clicked()
              {
                  QMovie*movie=new QMovie(":/somegif.gif");
                  qDebug() << "test1";
                      if(!movie->isValid()){
                          //something went Wrong
                          return;
                      }
                      //play GIF
                      auto label=new QLabel();
                      label->resize(400,180);
                      label->setMovie(movie);
                      label->show();
                      movie->start();
              
                      QTimer*timer=new QTimer(this);
                      connect(timer,SIGNAL(timeout()),this,SLOT(PrintDebugInTimer()));
                      timer->start(1000);
                      //start time to close it after 10 sec
                      QTimer::singleShot(10000,[label,&timer]{
                         // label->close();
                          label->deleteLater();
                          timer->stop();
                      });
              
                  Mat image = imread("/home/pi/test.jpg");
                  //Rect myROI(445, 745, 400, 400);
                  //Mat crop = image(myROI);
                  //imwrite("/home/pi/1.png", crop);
                  Mat roi1 = image( Rect(2000,730,400,400));
                  Mat roi2 = image( Rect(1220,720,400,400));
                  Mat roi3 = image( Rect(445,745,400,400));
                  imwrite("/home/pi/1.png", roi1);
                  imwrite("/home/pi/2.png", roi2);
                  imwrite("/home/pi/3.png", roi3);
              
                  digitalWrite(7,LOW);
                  digitalWrite(5,HIGH);
              
                  for(int i=0;i<(35*50);i++)
                  {
                      QCoreApplication::processEvents();
              
                      digitalWrite(4,1);
                      //delay(0.5);//for milliseconds
                      usleep(250);//for micro seconds
                      digitalWrite(4,0);
                      //delay(0.5);//for milliseconds
                      usleep(250);//for micro seconds
                  }
                  digitalWrite(7,HIGH);
                  popMessageBox();
                  Mat image1 = imread("/home/pi/test.jpg");
                  Mat roi4 = image1( Rect(2000,730,400,400));
                  Mat roi5 = image1( Rect(1220,720,400,400));
                  Mat roi6 = image1( Rect(445,745,400,400));
                  imwrite("/home/pi/4.png", roi4);
                  imwrite("/home/pi/5.png", roi5);
                  imwrite("/home/pi/6.png", roi6);
                  digitalWrite(7,LOW);
                  digitalWrite(5,HIGH);
              
                  for(int i=0;i<(34*50);i++)
                  {
                      QCoreApplication::processEvents();
              
                      digitalWrite(4,1);
                      //delay(0.5);//for milliseconds
                      usleep(250);//for micro seconds
                      digitalWrite(4,0);
                      //delay(0.5);//for milliseconds
                      usleep(250);//for micro seconds
                  }
                  digitalWrite(7,HIGH);
                  popMessageBox();
                  Mat image2 = imread("/home/pi/test.jpg");
                  Mat roi7 = image2( Rect(2000,730,400,400));
                  Mat roi8 = image2( Rect(1220,720,400,400));
                  Mat roi9 = image2( Rect(445,745,400,400));
                  imwrite("/home/pi/7.png", roi7);
                  imwrite("/home/pi/8.png", roi8);
                  imwrite("/home/pi/9.png", roi9);
                  digitalWrite(7,LOW);
                  digitalWrite(5,HIGH);
              
                  for(int i=0;i<(34*50);i++)
                  {
                      QCoreApplication::processEvents();
              
                      digitalWrite(4,1);
                      //delay(0.5);//for milliseconds
                      usleep(250);//for micro seconds
                      digitalWrite(4,0);
                      //delay(0.5);//for milliseconds
                      usleep(250);//for micro seconds
                  }
                  digitalWrite(7,HIGH);
                  popMessageBox();
                  Mat image3 = imread("/home/pi/test.jpg");
                  Mat roi10 = image3( Rect(2000,730,400,400));
                  Mat roi11 = image3( Rect(1220,720,400,400));
                  imwrite("/home/pi/10.png", roi10);
                  imwrite("/home/pi/11.png", roi11);
              
                  QPixmap pix1,pix2,pix3,pix4,pix5,pix6,pix7,pix8,pix9,pix10,pix11;
                  pix1.load("/home/pi/11.png");
                  pix2.load("/home/pi/10.png");
                  pix3.load("/home/pi/9.png");
                  pix4.load("/home/pi/8.png");
                  pix5.load("/home/pi/7.png");
                  pix6.load("/home/pi/6.png");
                  pix7.load("/home/pi/5.png");
                  pix8.load("/home/pi/4.png");
                  pix9.load("/home/pi/3.png");
                  pix10.load("/home/pi/2.png");
                  pix11.load("/home/pi/1.png");
                  pix1 = pix1.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                  pix2 = pix2.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                  pix3 = pix3.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                  pix4 = pix4.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                  pix5 = pix5.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                  pix6 = pix6.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                  pix7 = pix7.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                  pix8 = pix8.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                  pix9 = pix9.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                  pix10 = pix10.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
              
              
              
                  ui->label_3->setPixmap(pix1);
                  ui->label_4->setPixmap(pix2);
                  ui->label_5->setPixmap(pix3);
                  ui->label_6->setPixmap(pix4);
                  ui->label_7->setPixmap(pix5);
                  ui->label_8->setPixmap(pix6);
                  ui->label_9->setPixmap(pix7);
                  ui->label_10->setPixmap(pix8);
                  ui->label_11->setPixmap(pix9);
                  ui->label_12->setPixmap(pix10);
                  ui->label_13->setPixmap(pix11);
                  Scalar meanValue;
                  meanValue = mean(roi1);
                  
                  qDebug()<<meanValue[0];
                  qDebug()<<meanValue[1];
                  qDebug()<<meanValue[2];
              
              
              }
              
              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #12

              @sankarapandiyan said in Time delay in loading progress bar (GIF Format):

              So how to fix this problem

              Sorry I don't understand you. What exactly do you want to close and when?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              sankarapandiyanS 1 Reply Last reply
              0
              • jsulmJ jsulm

                @sankarapandiyan said in Time delay in loading progress bar (GIF Format):

                So how to fix this problem

                Sorry I don't understand you. What exactly do you want to close and when?

                sankarapandiyanS Offline
                sankarapandiyanS Offline
                sankarapandiyan
                wrote on last edited by
                #13

                @jsulm actually the push button (in the First window )pressed the progress bar runs first , After loading the progress bar window ( second window ). while closing second window simultaneously the first and second windows closed together , But what i want is i need to stay the ( First window ) on rest . i dont want to close ...

                jsulmJ 1 Reply Last reply
                0
                • sankarapandiyanS sankarapandiyan

                  @jsulm actually the push button (in the First window )pressed the progress bar runs first , After loading the progress bar window ( second window ). while closing second window simultaneously the first and second windows closed together , But what i want is i need to stay the ( First window ) on rest . i dont want to close ...

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #14

                  @sankarapandiyan Sorry, without code I have no idea...

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  sankarapandiyanS 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @sankarapandiyan Sorry, without code I have no idea...

                    sankarapandiyanS Offline
                    sankarapandiyanS Offline
                    sankarapandiyan
                    wrote on last edited by sankarapandiyan
                    #15

                    @jsulm @JonB @small_bird @mrjj

                    void MainWindow::on_pushButton_4_clicked()
                    {
                        QMovie*movie=new QMovie(":/somegif.gif");
                        qDebug() << "test1";
                            if(!movie->isValid()){
                                //something went Wrong
                                return;
                            }
                            //play GIF
                            auto label=new QLabel();
                            label->resize(400,180);
                            label->setMovie(movie);
                            label->show();
                            movie->start();
                    
                            QTimer*timer=new QTimer(this);
                            connect(timer,SIGNAL(timeout()),this,SLOT(PrintDebugInTimer()));
                            timer->start(1000);
                            //start time to close it after 10 sec
                            QTimer::singleShot(10000,[label,&timer]{
                               // label->close();
                                label->deleteLater();
                                timer->stop();
                            });
                    
                        Mat image = imread("/home/pi/test.jpg");
                        //Rect myROI(445, 745, 400, 400);
                        //Mat crop = image(myROI);
                        //imwrite("/home/pi/1.png", crop);
                        Mat roi1 = image( Rect(2000,730,400,400));
                        Mat roi2 = image( Rect(1220,720,400,400));
                        Mat roi3 = image( Rect(445,745,400,400));
                        imwrite("/home/pi/1.png", roi1);
                        imwrite("/home/pi/2.png", roi2);
                        imwrite("/home/pi/3.png", roi3);
                    
                        digitalWrite(7,LOW);
                        digitalWrite(5,HIGH);
                    
                        for(int i=0;i<(35*50);i++)
                        {
                            QCoreApplication::processEvents();
                    
                            digitalWrite(4,1);
                            //delay(0.5);//for milliseconds
                            usleep(250);//for micro seconds
                            digitalWrite(4,0);
                            //delay(0.5);//for milliseconds
                            usleep(250);//for micro seconds
                        }
                        digitalWrite(7,HIGH);
                        popMessageBox();
                        Mat image1 = imread("/home/pi/test.jpg");
                        Mat roi4 = image1( Rect(2000,730,400,400));
                        Mat roi5 = image1( Rect(1220,720,400,400));
                        Mat roi6 = image1( Rect(445,745,400,400));
                        imwrite("/home/pi/4.png", roi4);
                        imwrite("/home/pi/5.png", roi5);
                        imwrite("/home/pi/6.png", roi6);
                        digitalWrite(7,LOW);
                        digitalWrite(5,HIGH);
                    
                        for(int i=0;i<(34*50);i++)
                        {
                            QCoreApplication::processEvents();
                    
                            digitalWrite(4,1);
                            //delay(0.5);//for milliseconds
                            usleep(250);//for micro seconds
                            digitalWrite(4,0);
                            //delay(0.5);//for milliseconds
                            usleep(250);//for micro seconds
                        }
                        digitalWrite(7,HIGH);
                        popMessageBox();
                        Mat image2 = imread("/home/pi/test.jpg");
                        Mat roi7 = image2( Rect(2000,730,400,400));
                        Mat roi8 = image2( Rect(1220,720,400,400));
                        Mat roi9 = image2( Rect(445,745,400,400));
                        imwrite("/home/pi/7.png", roi7);
                        imwrite("/home/pi/8.png", roi8);
                        imwrite("/home/pi/9.png", roi9);
                        digitalWrite(7,LOW);
                        digitalWrite(5,HIGH);
                    
                        for(int i=0;i<(34*50);i++)
                        {
                            QCoreApplication::processEvents();
                    
                            digitalWrite(4,1);
                            //delay(0.5);//for milliseconds
                            usleep(250);//for micro seconds
                            digitalWrite(4,0);
                            //delay(0.5);//for milliseconds
                            usleep(250);//for micro seconds
                        }
                        digitalWrite(7,HIGH);
                        popMessageBox();
                        Mat image3 = imread("/home/pi/test.jpg");
                        Mat roi10 = image3( Rect(2000,730,400,400));
                        Mat roi11 = image3( Rect(1220,720,400,400));
                        imwrite("/home/pi/10.png", roi10);
                        imwrite("/home/pi/11.png", roi11);
                    
                        QPixmap pix1,pix2,pix3,pix4,pix5,pix6,pix7,pix8,pix9,pix10,pix11;
                        pix1.load("/home/pi/11.png");
                        pix2.load("/home/pi/10.png");
                        pix3.load("/home/pi/9.png");
                        pix4.load("/home/pi/8.png");
                        pix5.load("/home/pi/7.png");
                        pix6.load("/home/pi/6.png");
                        pix7.load("/home/pi/5.png");
                        pix8.load("/home/pi/4.png");
                        pix9.load("/home/pi/3.png");
                        pix10.load("/home/pi/2.png");
                        pix11.load("/home/pi/1.png");
                        pix1 = pix1.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                        pix2 = pix2.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                        pix3 = pix3.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                        pix4 = pix4.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                        pix5 = pix5.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                        pix6 = pix6.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                        pix7 = pix7.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                        pix8 = pix8.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                        pix9 = pix9.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                        pix10 = pix10.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                    
                    
                    
                        ui->label_3->setPixmap(pix1);
                        ui->label_4->setPixmap(pix2);
                        ui->label_5->setPixmap(pix3);
                        ui->label_6->setPixmap(pix4);
                        ui->label_7->setPixmap(pix5);
                        ui->label_8->setPixmap(pix6);
                        ui->label_9->setPixmap(pix7);
                        ui->label_10->setPixmap(pix8);
                        ui->label_11->setPixmap(pix9);
                        ui->label_12->setPixmap(pix10);
                        ui->label_13->setPixmap(pix11);
                        Scalar meanValue;
                        meanValue = mean(roi1);
                        
                        qDebug()<<meanValue[0];
                        qDebug()<<meanValue[1];
                        qDebug()<<meanValue[2];
                    
                    
                    }
                    

                    this is my output
                    i have checked

                    with q debug

                    https://postimg.cc/gallery/1e0w5cul2/

                    This is my code and this is my out put

                    jsulmJ 1 Reply Last reply
                    0
                    • sankarapandiyanS sankarapandiyan

                      @jsulm @JonB @small_bird @mrjj

                      void MainWindow::on_pushButton_4_clicked()
                      {
                          QMovie*movie=new QMovie(":/somegif.gif");
                          qDebug() << "test1";
                              if(!movie->isValid()){
                                  //something went Wrong
                                  return;
                              }
                              //play GIF
                              auto label=new QLabel();
                              label->resize(400,180);
                              label->setMovie(movie);
                              label->show();
                              movie->start();
                      
                              QTimer*timer=new QTimer(this);
                              connect(timer,SIGNAL(timeout()),this,SLOT(PrintDebugInTimer()));
                              timer->start(1000);
                              //start time to close it after 10 sec
                              QTimer::singleShot(10000,[label,&timer]{
                                 // label->close();
                                  label->deleteLater();
                                  timer->stop();
                              });
                      
                          Mat image = imread("/home/pi/test.jpg");
                          //Rect myROI(445, 745, 400, 400);
                          //Mat crop = image(myROI);
                          //imwrite("/home/pi/1.png", crop);
                          Mat roi1 = image( Rect(2000,730,400,400));
                          Mat roi2 = image( Rect(1220,720,400,400));
                          Mat roi3 = image( Rect(445,745,400,400));
                          imwrite("/home/pi/1.png", roi1);
                          imwrite("/home/pi/2.png", roi2);
                          imwrite("/home/pi/3.png", roi3);
                      
                          digitalWrite(7,LOW);
                          digitalWrite(5,HIGH);
                      
                          for(int i=0;i<(35*50);i++)
                          {
                              QCoreApplication::processEvents();
                      
                              digitalWrite(4,1);
                              //delay(0.5);//for milliseconds
                              usleep(250);//for micro seconds
                              digitalWrite(4,0);
                              //delay(0.5);//for milliseconds
                              usleep(250);//for micro seconds
                          }
                          digitalWrite(7,HIGH);
                          popMessageBox();
                          Mat image1 = imread("/home/pi/test.jpg");
                          Mat roi4 = image1( Rect(2000,730,400,400));
                          Mat roi5 = image1( Rect(1220,720,400,400));
                          Mat roi6 = image1( Rect(445,745,400,400));
                          imwrite("/home/pi/4.png", roi4);
                          imwrite("/home/pi/5.png", roi5);
                          imwrite("/home/pi/6.png", roi6);
                          digitalWrite(7,LOW);
                          digitalWrite(5,HIGH);
                      
                          for(int i=0;i<(34*50);i++)
                          {
                              QCoreApplication::processEvents();
                      
                              digitalWrite(4,1);
                              //delay(0.5);//for milliseconds
                              usleep(250);//for micro seconds
                              digitalWrite(4,0);
                              //delay(0.5);//for milliseconds
                              usleep(250);//for micro seconds
                          }
                          digitalWrite(7,HIGH);
                          popMessageBox();
                          Mat image2 = imread("/home/pi/test.jpg");
                          Mat roi7 = image2( Rect(2000,730,400,400));
                          Mat roi8 = image2( Rect(1220,720,400,400));
                          Mat roi9 = image2( Rect(445,745,400,400));
                          imwrite("/home/pi/7.png", roi7);
                          imwrite("/home/pi/8.png", roi8);
                          imwrite("/home/pi/9.png", roi9);
                          digitalWrite(7,LOW);
                          digitalWrite(5,HIGH);
                      
                          for(int i=0;i<(34*50);i++)
                          {
                              QCoreApplication::processEvents();
                      
                              digitalWrite(4,1);
                              //delay(0.5);//for milliseconds
                              usleep(250);//for micro seconds
                              digitalWrite(4,0);
                              //delay(0.5);//for milliseconds
                              usleep(250);//for micro seconds
                          }
                          digitalWrite(7,HIGH);
                          popMessageBox();
                          Mat image3 = imread("/home/pi/test.jpg");
                          Mat roi10 = image3( Rect(2000,730,400,400));
                          Mat roi11 = image3( Rect(1220,720,400,400));
                          imwrite("/home/pi/10.png", roi10);
                          imwrite("/home/pi/11.png", roi11);
                      
                          QPixmap pix1,pix2,pix3,pix4,pix5,pix6,pix7,pix8,pix9,pix10,pix11;
                          pix1.load("/home/pi/11.png");
                          pix2.load("/home/pi/10.png");
                          pix3.load("/home/pi/9.png");
                          pix4.load("/home/pi/8.png");
                          pix5.load("/home/pi/7.png");
                          pix6.load("/home/pi/6.png");
                          pix7.load("/home/pi/5.png");
                          pix8.load("/home/pi/4.png");
                          pix9.load("/home/pi/3.png");
                          pix10.load("/home/pi/2.png");
                          pix11.load("/home/pi/1.png");
                          pix1 = pix1.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                          pix2 = pix2.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                          pix3 = pix3.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                          pix4 = pix4.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                          pix5 = pix5.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                          pix6 = pix6.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                          pix7 = pix7.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                          pix8 = pix8.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                          pix9 = pix9.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                          pix10 = pix10.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                      
                      
                      
                          ui->label_3->setPixmap(pix1);
                          ui->label_4->setPixmap(pix2);
                          ui->label_5->setPixmap(pix3);
                          ui->label_6->setPixmap(pix4);
                          ui->label_7->setPixmap(pix5);
                          ui->label_8->setPixmap(pix6);
                          ui->label_9->setPixmap(pix7);
                          ui->label_10->setPixmap(pix8);
                          ui->label_11->setPixmap(pix9);
                          ui->label_12->setPixmap(pix10);
                          ui->label_13->setPixmap(pix11);
                          Scalar meanValue;
                          meanValue = mean(roi1);
                          
                          qDebug()<<meanValue[0];
                          qDebug()<<meanValue[1];
                          qDebug()<<meanValue[2];
                      
                      
                      }
                      

                      this is my output
                      i have checked

                      with q debug

                      https://postimg.cc/gallery/1e0w5cul2/

                      This is my code and this is my out put

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #16

                      @sankarapandiyan Well, your app is actually crashing. The code is pretty messy to be honest.

                      QTimer*timer=new QTimer(this);
                      connect(timer,SIGNAL(timeout()),this,SLOT(PrintDebugInTimer()));
                      timer->start(1000);
                      //start time to close it after 10 sec
                      QTimer::singleShot(10000,[label,&timer]{
                      // label->close();
                          label->deleteLater();
                          timer->stop(); // It crashes here. Means timer is already destroyed - do you delete it or its parent somewhere?
                      });
                      

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      sankarapandiyanS 2 Replies Last reply
                      1
                      • jsulmJ jsulm

                        @sankarapandiyan Well, your app is actually crashing. The code is pretty messy to be honest.

                        QTimer*timer=new QTimer(this);
                        connect(timer,SIGNAL(timeout()),this,SLOT(PrintDebugInTimer()));
                        timer->start(1000);
                        //start time to close it after 10 sec
                        QTimer::singleShot(10000,[label,&timer]{
                        // label->close();
                            label->deleteLater();
                            timer->stop(); // It crashes here. Means timer is already destroyed - do you delete it or its parent somewhere?
                        });
                        
                        sankarapandiyanS Offline
                        sankarapandiyanS Offline
                        sankarapandiyan
                        wrote on last edited by sankarapandiyan
                        #17
                        This post is deleted!
                        1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @sankarapandiyan Well, your app is actually crashing. The code is pretty messy to be honest.

                          QTimer*timer=new QTimer(this);
                          connect(timer,SIGNAL(timeout()),this,SLOT(PrintDebugInTimer()));
                          timer->start(1000);
                          //start time to close it after 10 sec
                          QTimer::singleShot(10000,[label,&timer]{
                          // label->close();
                              label->deleteLater();
                              timer->stop(); // It crashes here. Means timer is already destroyed - do you delete it or its parent somewhere?
                          });
                          
                          sankarapandiyanS Offline
                          sankarapandiyanS Offline
                          sankarapandiyan
                          wrote on last edited by
                          #18

                          @jsulm said in Time delay in loading progress bar (GIF Format):

                          It crashes here. Means timer is already destroyed

                          You are Absolutely Right!!!!!!

                          Now its Works .. Great Thanks ................ @jsulm @mrjj @JonB

                          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