Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Progress bar is not smooth
Forum Updated to NodeBB v4.3 + New Features

Progress bar is not smooth

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qtquickqmlprogress bar
18 Posts 5 Posters 3.5k 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.
  • D dan1973
    6 Sept 2022, 07:47

    @Witc said in Progress bar is not smooth:

    Do you think to set timer repeate to false?: When I do, the callback is called only once. When I added at the end of callback timer.start() - it still do the same - it "jumps" 100/80/..

    I tried using cpp and h files rather in Qml below it works smoothly. Maybe you should do some settings in Qml to make it fire at 20ms and set value of Progressbar each time by 1 unit.

    .h file

    #ifndef WIDGET_H
    #define WIDGET_H
    
    #include <QWidget>
    #include <QProgressBar>
    #include <QTimer>
    
    QT_BEGIN_NAMESPACE
    namespace Ui { class Widget; }
    QT_END_NAMESPACE
    
    class Widget : public QWidget
    {
        Q_OBJECT
    
    public:
        Widget(QWidget *parent = nullptr);
        ~Widget();
        int iTick;
    
    private slots:
        void MySlot();
        void vcPgb1(int);
    
    private:
        Ui::Widget *ui;
    
        QProgressBar* pgb1;
        QTimer* tmr1;
    };
    #endif // WIDGET_H
    

    .cpp file

    #include "widget.h"
    #include "ui_widget.h"
    #include <QDebug>
    
    Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) {
        ui->setupUi(this);
    
        iTick = 0;
        pgb1 = new QProgressBar(this);
        pgb1->setRange(0, 1000);
        pgb1->setGeometry(20, 100, 600, 30);
        connect(pgb1, SIGNAL(valueChanged(int)), this, SLOT(vcPgb1(int)));
    
        tmr1 = new QTimer(this);
        connect(tmr1, SIGNAL(timeout()), this, SLOT(MySlot()));
        tmr1->start(20);
    }
    
    Widget::~Widget() {
        tmr1->stop();
        delete ui;    
    }
    
    void Widget::MySlot() {
        iTick++;
        pgb1->setValue(iTick);
    }
    
    void Widget::vcPgb1(int iVal) {
        qDebug() << "pgb1 Value: " << iVal;
    }
    
    
    W Offline
    W Offline
    Witc
    wrote on 6 Sept 2022, 09:26 last edited by
    #6

    I tried using cpp and h files rather in Qml below it works smoothly. Maybe you should do some settings in Qml to make it fire at 20ms and set value of Progressbar each time by 1 unit.

    .h file

    #ifndef WIDGET_H
    #define WIDGET_H
    
    #include <QWidget>
    #include <QProgressBar>
    #include <QTimer>
    
    QT_BEGIN_NAMESPACE
    

    Also do not undesratnd well. But maybe? I tried this:

    import QtQuick 
    import QtQuick.Controls 6.3
    
    ApplicationWindow {
        id: root
        visible: true
        minimumWidth: 840
        minimumHeight: 600
    
        property real prgVal1:100
    
        function updateProgress(){
                if(prgVal1>0){
                    prgVal1 -= 0.1
                }
                else{
                    prgVal1 = 100
                }
                progressBar1.value = prgVal1
        }
             
    
        Timer{
            id:timProgress
            interval: 10
            running: true
            repeat: true
            onTriggered: {
                updateProgress()
            }
        }
    
        
        ProgressBar{
            id: progressBar1
            visible: true
            width: 100
            height: 40
            x: 20
            y: 50
            value: 66
            from:0
            to: 100
        }
    
    }
    
    
    /*##^##
    Designer {
        D{i:0;autoSize:true;height:480;width:640}D{i:2}D{i:3}D{i:4}D{i:5}D{i:6}D{i:1}
    }
    ##^##*/
    
    It also does not work to me.
    
    1 Reply Last reply
    0
    • D Offline
      D Offline
      dan1973
      wrote on 6 Sept 2022, 09:53 last edited by
      #7

      Try this in xml

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      
      ApplicationWindow {
          id: root
          visible: true
          minimumWidth: 840
          minimumHeight: 600
      
          property real prgVal1:100
      
          function updateProgress(){
                  if(prgVal1>0){
                      prgVal1 -= 0.1
                  }
                  else{
                      prgVal1 = 100
                  }
                  progressBar1.value = prgVal1
                  console.log("prgVal1 = ", prgVal1);
          }
      
      
          Timer{
              id:timProgress
              interval: 10
              running: true
              repeat: true
              onTriggered: {
                  updateProgress()
              }
          }
      
      
          ProgressBar{
              id: progressBar1
              visible: true
              width: 600
              height: 60
              x: 20
              y: 50
              value: 100
              from: 0
              to: 100
          }
      
      }
      
      
      W 1 Reply Last reply 6 Sept 2022, 11:26
      0
      • D dan1973
        6 Sept 2022, 09:53

        Try this in xml

        import QtQuick 2.15
        import QtQuick.Controls 2.15
        
        ApplicationWindow {
            id: root
            visible: true
            minimumWidth: 840
            minimumHeight: 600
        
            property real prgVal1:100
        
            function updateProgress(){
                    if(prgVal1>0){
                        prgVal1 -= 0.1
                    }
                    else{
                        prgVal1 = 100
                    }
                    progressBar1.value = prgVal1
                    console.log("prgVal1 = ", prgVal1);
            }
        
        
            Timer{
                id:timProgress
                interval: 10
                running: true
                repeat: true
                onTriggered: {
                    updateProgress()
                }
            }
        
        
            ProgressBar{
                id: progressBar1
                visible: true
                width: 600
                height: 60
                x: 20
                y: 50
                value: 100
                from: 0
                to: 100
            }
        
        }
        
        
        W Offline
        W Offline
        Witc
        wrote on 6 Sept 2022, 11:26 last edited by
        #8

        @dan1973 said in Progress bar is not smooth:

        import QtQuick 2.15
        import QtQuick.Controls 2.15

        It Still "jumps"... In console the prgVal is correct: 100/99,9/99,8/99,7/99,6....

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dan1973
          wrote on 6 Sept 2022, 12:07 last edited by
          #9

          @Witc said in Progress bar is not smooth:

          It Still "jumps"...

          what is the System configuration of yours: RAM, Processor and OS?

          W 1 Reply Last reply 6 Sept 2022, 12:43
          0
          • D Offline
            D Offline
            dan1973
            wrote on 6 Sept 2022, 12:31 last edited by
            #10

            I checked it is moving smoothly without breaks or jagging

            1 Reply Last reply
            0
            • D dan1973
              6 Sept 2022, 12:07

              @Witc said in Progress bar is not smooth:

              It Still "jumps"...

              what is the System configuration of yours: RAM, Processor and OS?

              W Offline
              W Offline
              Witc
              wrote on 6 Sept 2022, 12:43 last edited by
              #11

              @dan1973 said in Progress bar is not smooth:

              @Witc said in Progress bar is not smooth:

              It Still "jumps"...

              what is the System configuration of yours: RAM, Processor and OS?

              Now I tried the same app on my friends PC (Ubuntu)- and it works great.
              On my Windows 10, Dell, intel i7, 16GB RAM it is jagging

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dan1973
                wrote on 7 Sept 2022, 06:17 last edited by
                #12

                @Witc said in Progress bar is not smooth:

                On my Windows 10, Dell, intel i7, 16GB RAM it is jagging

                your config above is Good Enough. Normally Qt requires min 4GB and 16GB will be enough to run any graphics. when you say intel i7 what's the processor speed.

                You should check if any background process keeps windows busy in providing priority to your app. normally windows OS guarantees for more than 20ms.

                if its over please mark solved. or any questions you can ask?

                W 1 Reply Last reply 8 Sept 2022, 06:46
                0
                • D dan1973
                  7 Sept 2022, 06:17

                  @Witc said in Progress bar is not smooth:

                  On my Windows 10, Dell, intel i7, 16GB RAM it is jagging

                  your config above is Good Enough. Normally Qt requires min 4GB and 16GB will be enough to run any graphics. when you say intel i7 what's the processor speed.

                  You should check if any background process keeps windows busy in providing priority to your app. normally windows OS guarantees for more than 20ms.

                  if its over please mark solved. or any questions you can ask?

                  W Offline
                  W Offline
                  Witc
                  wrote on 8 Sept 2022, 06:46 last edited by
                  #13

                  @dan1973 said in Progress bar is not smooth:

                  if its over please mark solved. or any questions you can ask?

                  unfortunatelly I have no idea how to solve it on my Computer, @ndias has the same problem as me, so ther is probably some bug in some verision of Qt? Python?....

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    dan1973
                    wrote on 8 Sept 2022, 09:18 last edited by dan1973 9 Aug 2022, 09:19
                    #14

                    @Witc said in Progress bar is not smooth:

                    probably some bug in some verision of Qt?

                    which Qt version r u using? and which compiler?

                    W 1 Reply Last reply 9 Sept 2022, 06:55
                    0
                    • D dan1973
                      8 Sept 2022, 09:18

                      @Witc said in Progress bar is not smooth:

                      probably some bug in some verision of Qt?

                      which Qt version r u using? and which compiler?

                      W Offline
                      W Offline
                      Witc
                      wrote on 9 Sept 2022, 06:55 last edited by
                      #15

                      @dan1973 said in Progress bar is not smooth:

                      @Witc said in Progress bar is not smooth:

                      probably some bug in some verision of Qt?

                      which Qt version r u using? and which compiler?

                      QT 6.3.1: 512b515f-437e-4470-8a0d-0a289634780e-image.png

                      J 1 Reply Last reply 9 Sept 2022, 06:56
                      0
                      • W Witc
                        9 Sept 2022, 06:55

                        @dan1973 said in Progress bar is not smooth:

                        @Witc said in Progress bar is not smooth:

                        probably some bug in some verision of Qt?

                        which Qt version r u using? and which compiler?

                        QT 6.3.1: 512b515f-437e-4470-8a0d-0a289634780e-image.png

                        J Offline
                        J Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 9 Sept 2022, 06:56 last edited by
                        #16

                        @Witc This does not answer the question which compiler you're using as you installed Qt for ARM64, MSVC2019, WebAssembly, Android and MinGW...

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

                        W 1 Reply Last reply 9 Sept 2022, 08:01
                        0
                        • J jsulm
                          9 Sept 2022, 06:56

                          @Witc This does not answer the question which compiler you're using as you installed Qt for ARM64, MSVC2019, WebAssembly, Android and MinGW...

                          W Offline
                          W Offline
                          Witc
                          wrote on 9 Sept 2022, 08:01 last edited by Witc 9 Sept 2022, 08:10
                          #17

                          @jsulm said in Progress bar is not smooth:

                          @Witc This does not answer the question which compiler you're using as you installed Qt for ARM64, MSVC2019, WebAssembly, Android and MinGW...

                          I am using Qt along with python 3.10 + Pyside6. No any line of my code is written in C/C++ ...

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            Marko Stanke
                            wrote on 12 Sept 2022, 15:18 last edited by
                            #18

                            Tried it on Qt 5.15, and it works perfectly

                            1 Reply Last reply
                            0

                            15/18

                            9 Sept 2022, 06:55

                            • Login

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