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. QDoubleSpinBox valueChanged has called twice
QtWS25 Last Chance

QDoubleSpinBox valueChanged has called twice

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 672 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.
  • P Offline
    P Offline
    Peiqi.Liu
    wrote on 6 Sept 2020, 13:35 last edited by Peiqi.Liu 9 Jul 2020, 01:30
    #1

    Qt 5.15.0 Release Win32

    ①、when I call on_nudBm3d_valueChanged(), this function will call twice.

    void QtImageProcessing::on_nudBm3d_valueChanged()
    {
        if (checkQImage(image1))
        {
            cv::Mat src = QImageToMat(image1);
            cv::Mat dst;
    
            int64 t1 = cv::getTickCount();
            cv::xphoto::bm3dDenoising(src, dst,
                ui.nudBm3dH->value(),
                ui.nudBm3dTemplateWindowSize->value(),
                ui.nudBm3dSearchWindowSize->value(),
                ui.nudBm3dBlockMatchingStep1->value(),
                ui.nudBm3dBlockMatchingStep2->value(),
                ui.nudBm3dGroupSize->value(),
                ui.nudBm3dSlidingStep->value(),
                ui.nudBm3dBeta->value());
            int64 t2 = cv::getTickCount();
    
            showImageInPicturebox2(MatToQImage(dst));
            qDebug() << QTime::currentTime() << qPrintable("  QDoubleSpinBox value: ") << ui.nudBm3dH->value();
            qDebug() << qPrintable("cv::xphoto::bm3dDenoising(): ") << (t2 - t1) / cv::getTickFrequency() * 1000 << qPrintable(" ms");
        }
    }
    

    截屏图片 (2).jpg

    ②、if I change code to below, only call one time.

    void QtImageProcessing::on_nudBm3d_valueChanged()
    {
        if (checkQImage(image1))
        {
            cv::Mat src = QImageToMat(image1);
            cv::Mat dst;
    
            int64 t1 = cv::getTickCount();
            //do nothing...
            int64 t2 = cv::getTickCount();
    
            showImageInPicturebox2(MatToQImage(dst));
            qDebug() << QTime::currentTime() << qPrintable("  QDoubleSpinBox value: ") << ui.nudBm3dH->value();
            qDebug() << qPrintable("cv::xphoto::bm3dDenoising(): ") << (t2 - t1) / cv::getTickFrequency() * 1000 << qPrintable(" ms");
        }
    }
    

    截屏图片 (3).jpg

    P 1 Reply Last reply 6 Sept 2020, 14:46
    0
    • P Peiqi.Liu
      6 Sept 2020, 13:35

      Qt 5.15.0 Release Win32

      ①、when I call on_nudBm3d_valueChanged(), this function will call twice.

      void QtImageProcessing::on_nudBm3d_valueChanged()
      {
          if (checkQImage(image1))
          {
              cv::Mat src = QImageToMat(image1);
              cv::Mat dst;
      
              int64 t1 = cv::getTickCount();
              cv::xphoto::bm3dDenoising(src, dst,
                  ui.nudBm3dH->value(),
                  ui.nudBm3dTemplateWindowSize->value(),
                  ui.nudBm3dSearchWindowSize->value(),
                  ui.nudBm3dBlockMatchingStep1->value(),
                  ui.nudBm3dBlockMatchingStep2->value(),
                  ui.nudBm3dGroupSize->value(),
                  ui.nudBm3dSlidingStep->value(),
                  ui.nudBm3dBeta->value());
              int64 t2 = cv::getTickCount();
      
              showImageInPicturebox2(MatToQImage(dst));
              qDebug() << QTime::currentTime() << qPrintable("  QDoubleSpinBox value: ") << ui.nudBm3dH->value();
              qDebug() << qPrintable("cv::xphoto::bm3dDenoising(): ") << (t2 - t1) / cv::getTickFrequency() * 1000 << qPrintable(" ms");
          }
      }
      

      截屏图片 (2).jpg

      ②、if I change code to below, only call one time.

      void QtImageProcessing::on_nudBm3d_valueChanged()
      {
          if (checkQImage(image1))
          {
              cv::Mat src = QImageToMat(image1);
              cv::Mat dst;
      
              int64 t1 = cv::getTickCount();
              //do nothing...
              int64 t2 = cv::getTickCount();
      
              showImageInPicturebox2(MatToQImage(dst));
              qDebug() << QTime::currentTime() << qPrintable("  QDoubleSpinBox value: ") << ui.nudBm3dH->value();
              qDebug() << qPrintable("cv::xphoto::bm3dDenoising(): ") << (t2 - t1) / cv::getTickFrequency() * 1000 << qPrintable(" ms");
          }
      }
      

      截屏图片 (3).jpg

      P Offline
      P Offline
      Pl45m4
      wrote on 6 Sept 2020, 14:46 last edited by Pl45m4 9 Jun 2020, 14:50
      #2

      @Peiqi-Liu

      Looks like your value has increased from 1.1 to 1.2?! Is there only one QDoubleSpinBox ? Are other spinBoxes connected to that slot?
      The OCV function shouldn't change that value directly, so it must change because of something else.

      Debug line by line and see what happens exactly.

      Edit:

      Does showImageInPicturebox2(MatToQImage(dst)); OR cv::xphoto::bm3dDenoising(src, dst, [ . . . ] ) change your GUI and / or member var values (especially ui.nudBm3dH->value), so that on_nudBm3d_valueChanged() is called again ?


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      P 2 Replies Last reply 6 Sept 2020, 15:51
      0
      • P Pl45m4
        6 Sept 2020, 14:46

        @Peiqi-Liu

        Looks like your value has increased from 1.1 to 1.2?! Is there only one QDoubleSpinBox ? Are other spinBoxes connected to that slot?
        The OCV function shouldn't change that value directly, so it must change because of something else.

        Debug line by line and see what happens exactly.

        Edit:

        Does showImageInPicturebox2(MatToQImage(dst)); OR cv::xphoto::bm3dDenoising(src, dst, [ . . . ] ) change your GUI and / or member var values (especially ui.nudBm3dH->value), so that on_nudBm3d_valueChanged() is called again ?

        P Offline
        P Offline
        Peiqi.Liu
        wrote on 6 Sept 2020, 15:51 last edited by Peiqi.Liu 9 Jun 2020, 15:57
        #3

        @Pl45m4 My GUI has 6 QSpinBox and 2 QDoubleSpinBox , all connect to on_nudBm3d_valueChanged() ,when I changed any QDoubleSpinBox or QSpinBox value, valueChanged called twice, value will changed twice too.
        showImageInPicturebox2() and cv::xphoto::bm3dDenoising() can't change GUI SpinBox value.
        cv::xphoto::bm3dDenoising() is a slow function , if I change it to another fast function ,valueChanged only call one time.

        1 Reply Last reply
        0
        • P Pl45m4
          6 Sept 2020, 14:46

          @Peiqi-Liu

          Looks like your value has increased from 1.1 to 1.2?! Is there only one QDoubleSpinBox ? Are other spinBoxes connected to that slot?
          The OCV function shouldn't change that value directly, so it must change because of something else.

          Debug line by line and see what happens exactly.

          Edit:

          Does showImageInPicturebox2(MatToQImage(dst)); OR cv::xphoto::bm3dDenoising(src, dst, [ . . . ] ) change your GUI and / or member var values (especially ui.nudBm3dH->value), so that on_nudBm3d_valueChanged() is called again ?

          P Offline
          P Offline
          Peiqi.Liu
          wrote on 6 Sept 2020, 16:13 last edited by
          #4

          @Pl45m4 I found https://bugreports.qt.io/browse/QTBUG-33128 is similar with my situation, but QT developer think this issue only happed in a Debug build so its not a major issue, BUT this problem happed in Release build on my project!!!

          1 Reply Last reply
          0
          • C Online
            C Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on 6 Sept 2020, 16:32 last edited by
            #5

            I don't see what this bugreport should fit to your problem... you most likely have some signal/slot loop when one spinbox changes it's value and emits a signal which is then connected to another spinbox. Provide a compilable example if you think it's a bug in Qt.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            P 1 Reply Last reply 7 Sept 2020, 03:35
            1
            • P Offline
              P Offline
              Peiqi.Liu
              wrote on 7 Sept 2020, 01:58 last edited by Peiqi.Liu 9 Jul 2020, 02:07
              #6

              I'm certain if valueChanged cost 500ms or more,valueChanged will call twice, and SpinBox value also increase twice. There is any timer use inside SpinBox?
              I change Win32 to X64, cv::xphoto::bm3dDenoising() use 400ms, and valueChanged() only call one time.

              1 Reply Last reply
              0
              • C Christian Ehrlicher
                6 Sept 2020, 16:32

                I don't see what this bugreport should fit to your problem... you most likely have some signal/slot loop when one spinbox changes it's value and emits a signal which is then connected to another spinbox. Provide a compilable example if you think it's a bug in Qt.

                P Offline
                P Offline
                Peiqi.Liu
                wrote on 7 Sept 2020, 03:35 last edited by Peiqi.Liu 9 Jul 2020, 03:38
                #7

                @Christian-Ehrlicher I do not have enough privileges to upload file.

                void MainWindow::on_doubleSpinBox_valueChanged(double arg1)
                {
                    Sleep(600);
                    qDebug()<<"called...";
                }
                
                1 Reply Last reply
                0

                4/7

                6 Sept 2020, 16:13

                • Login

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