[Qt-interest] qprocess related with qprogressbar

mierdatutis mi mmm286 at gmail.com
Sat Jun 27 04:14:50 CEST 2009


Many thanks again.
I put in my shell script, some outpouts to stdout that the function
that read all the output of the script can compare the string and can
increment the progress bar.
The problem that I have is that the progressbardialog dissapear every
time that the program enter in the output capture. Could I do that the
progressbar is always on top?

Many thanks

This is the code:

void MainWindowImpl::salida()
{
	QStringList strs;
	
    QByteArray result=proc2->readAllStandardOutput();
    qDebug() << proc2->readAllStandardOutput();

    QStringList lines = QString(result).split("\n");
    foreach (QString line, lines) {
        texto->append(line);
        qDebug() << line;

    QProgressDialog progress("DESCARANDO SINOPSIS...", "&Wake Up!", 0, 7, 0);
	progress.setWindowModality(Qt::WindowModal);
   	progress.show();	


	progress.setRange(0,100);
	progress.setValue(0);
	QString strss = "hola";
			qDebug() << "El valor es.." << line;
			qDebug() << "el valor de comparaicon es .." << strss;
	QString strxx;
		
		
	

	
		if ( line.compare("hola",Qt::CaseInsensitive)) {
			qDebug() << " NO HEMOS ENTRADO";
		}
		else {
			qDebug() << "ENTRADO";
			
						
			progress.setValue(10);
			progress.setFocus();
		}
			
		
		if ( line.compare("hola2",Qt::CaseInsensitive)) {
			qDebug() << " NO HEMOS ENTRADO";
		}
		else {
			qDebug() << "ENTRADO";
			progress.setValue(30);
		}	
			
		if ( line.compare("hola3",Qt::CaseInsensitive)) {
			qDebug() << " NO HEMOS ENTRADO";
		}
		else {
			qDebug() << "ENTRADO";
			progress.setValue(40);
		}
			
		
		if ( line.compare("hola4",Qt::CaseInsensitive)) {
			qDebug() << " NO HEMOS ENTRADO";
		}
		else {
			qDebug() << "ENTRADO";
			progress.setValue(50);
		}	
		
		if ( line.compare("hola5",Qt::CaseInsensitive)) {
			qDebug() << " NO HEMOS ENTRADO";
		}
		else {
			qDebug() << "ENTRADO";
			progress.setValue(60);
		}
			
		
		if ( line.compare("hola6",Qt::CaseInsensitive)) {
			qDebug() << " NO HEMOS ENTRADO";
		}
		else {
			qDebug() << "ENTRADO";
			progress.setValue(100);
		}	
		
	
		
    }
   }

Regards,


2009/6/26, Sean Harmer <sean.harmer at maps-technology.com>:
> Hi Again,
>
> On Friday 26 Jun 2009 06:45:08 mierdatutis mi wrote:
>> I try with this code but the compiler gives me an error:
>>
>> "Program received signal SIGSERV. Segmentation fault"
> Just spotted the error...
>
>> class MainWindowImpl : public QMainWindow, public Ui::MainWindow
>> {
>> Q_OBJECT
>> public:
>> MainWindowImpl( QWidget * parent = 0, Qt::WFlags f = 0 );
>>
>> private slots:
>> void cambio(QListWidgetItem*);
>> void salida();
>> public slots:
>> void doSomething();
>> private:
>> QProcess *proc2;
> You declare proc2 here...
> <snip>
>>  MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f)
>> : QMainWindow(parent, f)
>> {
>> setupUi(this);
>> QDir dir;
>> //showFullScreen();
>> QProcess *proc2 = new QProcess();
> And then hide the proc2 that you declared earlier. This should be:
> proc2 = new QProcess( this );
>
> With your original code the member variable proc2 never gets set to point at
> a
> valid memory address.
>
> I respectfully suggest that you go read some books on basic C++ programming
> and general development processes. Once you understand basic C++ take a look
> at the Qt tutorials and examples included in the distribution.
>
> All the best,
>
> Sean
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



More information about the Qt-interest-old mailing list