Results 1 to 8 of 8

Thread: ummm...cursor not changing...

  1. #1
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy 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

    Qt Code:
    1. QProcess launch_prog;
    2.  
    3. launch_prog.startDetached(path);
    4.  
    5. if(launch_prog.waitForStarted())
    6. setCursor(Qt::WaitCursor); //my widget inherits QWidget
    7.  
    8. if(launch_prog.state()==QProcess::Running);
    9. unsetCursor();
    To copy to clipboard, switch view to plain text mode 

    Thanks

    Nupul

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: ummm...cursor not changing...

    QProcess::startDetached() 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.
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ummm...cursor not changing...

    Qt Code:
    1. QApplication::setOverrideCursor(Qt::BusyCursor);
    2. QProcess launch_prog;
    3. launch_prog.start(path);
    4. QApplication::restoreOverrideCursor();
    To copy to clipboard, switch view to plain text mode 
    Save yourself some pain. Learn C++ before learning Qt.

  4. #4
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face ummm...cursor not changing...

    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

  5. #5
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Angry Re: ummm...cursor not changing...

    CBM, I even did as you said...actually I saw your reply later and edited my post

    This is what I did
    Qt Code:
    1. QApplication::setOverrideCursor(Qt::WaitCursor);
    2. locate.waitForFinished(-1);
    3. QApplication::restoreOverrideCursor();
    To copy to clipboard, switch view to plain text mode 

    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

    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
    Last edited by nupul; 4th May 2006 at 13:36.

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: ummm...cursor not changing...

    Qt Code:
    1. #include <QApplication>
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  7. #7
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Angry Re: ummm...cursor not changing...

    That was the first thing to cross my mind...did that too...but it still wouldn't work!!

  8. #8
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ummm...cursor not changing...

    Quote Originally Posted by nupul
    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:

    Qt Code:
    1. QApplication::setOverrideCursor(Qt::BusyCursor);
    2. QProcess* launch_prog = new QProcess(this);
    3. connect(launch_prog,
    4. SIGNAL(finished(int, QProcess::ExitStatus) ),
    5. launch_prog,
    6. SLOT(deleteLater()));
    7. launch_prog->start(path);
    8. QApplication::restoreOverrideCursor();
    To copy to clipboard, switch view to plain text mode 
    Last edited by Chicken Blood Machine; 4th May 2006 at 17:00.
    Save yourself some pain. Learn C++ before learning Qt.

  9. The following user says thank you to Chicken Blood Machine for this useful post:

    nupul (5th May 2006)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.