[Qt-interest] Maintaining a map of QProcesses
Wm. G. Urquhart
wgu at wurquhart.co.uk
Tue Nov 24 14:30:48 CET 2009
Wm. G. Urquhart wrote:
> Hi,
>
> I have an application that I want to use to launch other processes from
> based on the user's actions. These processes will be an instance of the
> same application but with different parameters passed to them. For
> example "Notepad.exe" "text1.txt" and "Notepad.exe" "text2.txt".
>
> At present I'm keeping the * of the process in a map along with an ID as
> the key but ideally, what I'd like to be able to do is when any of the
> processes state changes I would like to be notified of this so I can
> clean up my UI and perform housekeeping on the map. I know there is a
> stateChange slot but how to tie this all together and knowing which
> process raised it is where I'm confused.
>
> I'd really appreciate your thoughts on this.
While working on a solution I have a class derived from QObject and in
the classes constructor I want to connect the various signals from the
QProcess to their slots.
However, connect(...) returns false when I try this even though IFAICT
it should work. On page 311 of the C++ GUI Programming with Qt4 book
they are doing something similar only using QDialog.
if (!connect(m_Process, SIGNAL(stateChanged(QProcess::ProcessState)),
this, SLOT(processDone(QProcess::ProcessState))))
{
::QMessageBox::critical(0, "Oops", "Unable to connect slot!") ;
}
I have tried using QProcess as both a pointer and reference, but neither
work. Does anyone have any idea to what or where I'm going wrong?
--
William
More information about the Qt-interest-old
mailing list