updating a qprogressbar with qfuturewatcher



  • I have searched all over the net, but everyone seems to be using a lame qprogressdialog, like I want another $*%& dialog to deal with. Anyway i am trying to update a qprogressbar with the following code.

        QFuture<void> videoscan = QtConcurrent::map(videofiles, pvideo );
        QFutureWatcher<void> scanwatcher;
        QObject::connect(&scanwatcher, SIGNAL(progressRangeChanged(int,int)),progress, SLOT(setRange(int,int)));
        QObject::connect(&scanwatcher, SIGNAL(progressValueChanged(int)), progress, SLOT(setValue(int)));
        scanwatcher.setFuture(videoscan);
    

    the qprogressbar is in the constructor for MainWindow like this

        progress = new QProgressBar(ui->statusbar);
        statuslabel.setPalette(ui->statusbar->palette());
        statuslabel.setText("Idle");
        progress->setVisible(true);
        progress->setMinimum(0);
        ui->statusbar->addWidget(&statuslabel);
        ui->statusbar->addPermanentWidget(progress);
    

    I do not get any errors, the progressbar is just not updated, what am I missing?



  • haha solved it. I had to make qfuturewatcher and qfuture member declarations and move the connect calls to the MainWindow constructor and it works!!!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.