[Gambas-user] Issue 272 in gambas: Progress bars lack the "pulse" property for intermediate progress bar

gambas at ...2524... gambas at ...2524...
Sun Jul 15 03:43:08 CEST 2012


Comment #3 on issue 272 by adrien.p... at ...626...: Progress bars lack  
the "pulse" property for intermediate progress bar
http://code.google.com/p/gambas/issues/detail?id=272

The Qt doc speaks of a "busy indicator" if the range is set to 0 :

http://doc.qt.nokia.com/4.7-snapshot/qprogressbar.html#details

I tried, and it works, but you have to increase the value of the  
progressbar with a timer in order to make the progressbar move :

class Widget : public QProgressBar
{
     Q_OBJECT

public:
     explicit Widget(QWidget *parent = 0);
     ~Widget();

public slots:
     void pulse();

private:
     QTimer *pulseTimer;
};

Widget::Widget(QWidget *parent) :
     QProgressBar(parent)
{
     this->setRange(0, 0);

     pulseTimer = new QTimer;
     pulseTimer->setInterval(100);
     connect(pulseTimer, SIGNAL(timeout()), this, SLOT(pulse()));
     pulseTimer->start();
}

Widget::~Widget()
{

}

void Widget::pulse()
{
     this->setValue(this->value() + 2);

}

#include <QApplication>
#include "widget.h"

int main(int argc, char *argv[])
{
     QApplication a(argc, argv);
     Widget w;
     w.show();

     return a.exec();
}


(... even if I don't think this is a nice way, because the progressbar  
value can exceed the integer limits ... however, it can be useful in some  
cases)





More information about the User mailing list