Progress bar is not smooth
-
I use progress bar (QML/Pyside), although I decrease the Value (by one) of progress bar every 20 ms (does not matter it is same for 1 and 100 ms), it looks like the Progress bar jumps from 100->80->60->40->20->0. There are not smooth progress 100,99,98,97,96.... What am I doing wrong?
Timer{ id:timProgress interval: 20 running: true repeat: true onTriggered: { if(prgVal1>0){ prgVal1 = prgVal1-0.1 } } }
ProgressBar{ id: progressBar1 visible: true width: 60 height: 20 value: prgVal1 from:0 to: 100 }
You can see GIF here: https://ibb.co/Wk4w2bn
Can anyone help me please? -
I was able to reproduce the problem on my side. I have tested it using Qt6 on Windows OS.
If no one provides feedback on how to resolve the issue, maybee you can open a new ticket on bug report system providing a description and a minimal script reproducing the issue.
Regards
-
@dan1973 said in Progress bar is not smooth:
"repeat: true" should be "repeat: false"
i think the timer function onTriggered: is repeated continuously to make the prgVal1 reach from100 to 80 and 80 to 60...
Please check
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/...
-
@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; }
-
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.
-
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 } }
-
@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 -
@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?
-
@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?....
-
@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:
-
@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++ ...
-
Tried it on Qt 5.15, and it works perfectly