View Full Version : ummm...cursor not changing...
I have a few buttons in my app, which when clicked, launch a particular application, using QProcess.
Now what I want to do is this, till the external application hasn't started, I wish the Hourglass cursor to
be displayed. Once the application starts, reset the cursor to the original state. I tried several combinations
to the following code snippet, but can't seem to figure it out though...help ;)
QProcess launch_prog;
launch_prog.startDetached(path);
if(launch_prog.waitForStarted())
setCursor(Qt::WaitCursor); //my widget inherits QWidget
if(launch_prog.state()==QProcess::Running);
unsetCursor();
Thanks
Nupul
QProcess::startDetached() (http://doc.trolltech.com/4.1/qprocess.html#startDetached-2) is a static method. It returns true on success and false otherwise, and that's about all you will know about the launched process.
Instantiate a QProcess and handle it by non-static members instead, if you want to know more about it's state or so.
Chicken Blood Machine
3rd May 2006, 19:19
QApplication::setOverrideCursor(Qt::BusyCursor);
QProcess launch_prog;
launch_prog.start(path);
QApplication::restoreOverrideCursor();
already done that...in fact i get a warning msg displaying object destroyed while process is still running...and thus chose startDetached(...)
Maybe you could stick a few lines of code (or pseudo ;) )to explain what i should do!
Thanks
Nupul
CBM, I even did as you said...actually I saw your reply later and edited my post ;)
This is what I did
QApplication::setOverrideCursor(Qt::WaitCursor);
locate.waitForFinished(-1);
QApplication::restoreOverrideCursor();
And this is the error I got:
mylayout.cpp: In member function ‘void MyMenuLayout::search()’:
mylayout.cpp:488: error: incomplete type ‘QApplication’ used in nested name specifier
mylayout.cpp:490: error: incomplete type ‘QApplication’ used in nested name specifier
make: *** [mylayout.o] Error 1
infact I don't even know what it means :confused:
I went through the docs, and the exact same thing is done in one of the examples: A text editor.
What is wrong?
Thanks
Nupul
PS: i am executing the above on linux....if that's got something to do with this
:p
That was the first thing to cross my mind...did that too...but it still wouldn't work!!:eek:
Chicken Blood Machine
4th May 2006, 16:57
already done that...in fact i get a warning msg displaying object destroyed while process is still running...and thus chose startDetached(...)
Maybe you could stick a few lines of code (or pseudo ;) )to explain what i should do!
Thanks
Nupul
Oops, that should be:
QApplication::setOverrideCursor(Qt::BusyCursor);
QProcess* launch_prog = new QProcess(this);
connect(launch_prog,
SIGNAL(finished(int, QProcess::ExitStatus) ),
launch_prog,
SLOT(deleteLater()));
launch_prog->start(path);
QApplication::restoreOverrideCursor();
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.