i have this code but it is not working.i am trying to update progressbar while my video is converting.video conversion is fine but progessbar is not updating
void MainWindow::on_pushButton_clicked()
{
QString alienpath="ffmpeg";
QStringList argument;
argument<<"-i"<<ui->lineEdit->text()<<"/home/suraj/a.flv";
QProcess *alien=new QProcess(this);
alien->start(alienpath,argument);
int p;
p=alien->readAll().toInt();
ui->progressBar->setMaximum(0);
ui->progressBar->setMinimum(100);
ui->progressBar->setValue(p);
}
plz help
QTimer
orreadyRead
/readyReadStandardOutput
signal connecting to some slot in MainWindow or C++11 lambda, but I'm not sure what the output will contain in each time, so I can't tell if this will work.toInt()
is likely to fail. It works only if your output contains pure number like67
; the application usually produces a lot of output. UseQRegExp
orQRegularExpression
(Qt5) to extract digits and convert only them.toInt()
supports checking if a conversion error has occured, see documentation.