PDA

View Full Version : QProcess+QProgressBar



Kokosinys
19th June 2015, 13:20
Hello.

Please help me with QProgressbar.
Running script bash QProcess and output performance QProgressbar.


#include "widget.h"
#include "ui_widget.h"
#include <QProcess>
#include <QProgressBar>

Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}

Widget::~Widget()
{
delete ui;
}

void Widget::on_pushButton_2_clicked()
{
QProcess process(this);
process.startDetached("/bin/bash /opt/tall/ttings.sh");
}

void Widget::on_progressBar_valueChanged(int value)
{

}
I'm quite newbie to qt.
If possible. Sample code.

yeye_olive
19th June 2015, 13:53
What do you mean by "output performance QProgressbar"? I understand that you want to run a bash command and display a progress bar, but you have not explained the expected connection between those two things.

Kokosinys
19th June 2015, 17:08
What do you mean by "output performance QProgressbar"? I understand that you want to run a bash command and display a progress bar, but you have not explained the expected connection between those two things.
QProgressbar progress of the script bash.

ChrisW67
19th June 2015, 20:53
How does the shell script report its progress?

Kokosinys
20th June 2015, 11:06
How does the shell script report its progress?
Script long.
The code has a label:
echo "progress=1"
echo "progress=3"
echo "progress=6"...
Can they be transferred to the QProgressBar?

Sorry. Originally from Azerbaijan. My English is poor.
Do not be angry;)

anda_skoa
20th June 2015, 12:27
First you need to start the process in a way that QProcess stays connected to the script, i.e. not using startDetached (which as the name suggests detaches from the process after start).

Then you need to react to the QProcess signals that indicate that the script has written output.
Then you parse that output.
Then you change the progressbar accordingly.

Cheers,
_