[Interest] Gracefully Closing a QProcess

2014-08-08 Thread Jason R. Kretzer

Good Day!

I saw a partial question and answer to this a bit ago on this list but I 
have a follow up scenario.


I would like to start a QProcess and connect a SLOT to its 
SIGNAL(error(QProcess::ProcessError))


In the SLOT, I would like to gracefully restart the process without 
triggering the error signal.


I have tried several ways but must be missing something.  Here is some 
sample code that I have been tinkering with:


///START CODE/
//in an method in the this object
QProcess *proc = new QProcess();
QStringList arguments;
arguments  str1  str2  str3;
proc-setArguments(arguments);
proc-setProgram(something.exe);

connect(proc, SIGNAL(error(QProcess::ProcessError)), this, 
SLOT(restartProcess(QProcess::ProcessError)));

connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
proc-start();

//in the same file
void MainWindow::restartProcess(QProcess::ProcessError err)
{
QProcess *proc = static_castQProcess*(sender());

qDebug()  KILLING;
proc-close();
//**
//I have used proc-kill() and proc-terminate() here as well
//**


qDebug()  RESTARTING;
proc-start();
}
/END CODE

So, what happens is that the proc triggers an error when I 
kill/terminate/close it.  Which triggers the function, which kills the 
process, which triggers the error  etc etc.


In the end, not sure what is the right way to go about this. All I 
want to do is terminate and restart a process that has triggered an error.


Thoughts?

--
//---//
Jason R. Kretzer
Lead Application Developer
ja...@gocodigo.com
C:606.792.0079
H:606.297.2551
//---//
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] QHash memory management

2014-08-05 Thread Jason R. Kretzer

Just a quick question about using QHash with pointers.

Lets say I have the following snippet:

//===

QWebView *view;
QHashint, QWebView * hash;

for(int i=0; i10; i++) {
view = new QWebView(this);
hash.insert(i, view);
}

go do something meaningful

//or do a hash.clear();
for(int j=0; j10; j++) {
hash.remove(j);
}

//===


After the remove or clear is called, do I still need to delete the 
pointers?  If so, would I just iterate through them using the value 
function and delete them one by one?


-Jason

--
//---//
Jason R. Kretzer
Lead Application Developer
ja...@gocodigo.com
C:606.792.0079
H:606.297.2551
//---//
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest