Results 1 to 5 of 5

Thread: Cursor not changing

  1. #1
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Cursor not changing

    I have a class that inherits from QMainWindow called CMainForm.

    I have a menu action that triggers a method called menuPackageLogs().

    At the begining of the method I set the cursor to Qt::WaitCursor, and at the end I set it back to Qt::ArrowCursor. In between I call a routine that blocks for a while. The problem is that my cursor never changes. It is always an arrow, never an hour glass.

    I must be missing something fundemental here.
    Here is an example of the method that gets called:

    Qt Code:
    1. void CMainForm::menuPackageLogs()
    2. {
    3. // Change cursor to wait cursor
    4. setCursor(QCursor(Qt::WaitCursor));
    5.  
    6. bool bRet = UpgradeUtils::PackageLogs();
    7.  
    8. // Change cursor back to standard arrow
    9. setCursor(QCursor(Qt::ArrowCursor));
    10.  
    11. if (bRet == true)
    12. {
    13. QMessageBox::warning(this, tr("Package Logs"),
    14. "Upgrade log files successfully packaged.");
    15. }
    16. else
    17. {
    18. QMessageBox::warning(this, tr("Package Logs"),
    19. "Could not package Upgrade log files.");
    20. }
    21. }
    To copy to clipboard, switch view to plain text mode 

    If anyone has any ideas, I am all ears. Thanks.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Cursor not changing

    Are you sure this function is executed?
    If it is, then maybe the PackageLogs exits very fast so you don't have time to see the difference.

    Try adding QThread::msleep(5000); before or after the function call.See if you notice any difference.

    Regards

  3. #3
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Cursor not changing

    I did a sleep() for 15 seconds... with no luck. My application just hangs till it is done sleeping. The cursor never changes.

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Cursor not changing

    Yes, use QApplication::setOverrideCursor to set the busy cursor and QApplication::resoreOverrideCursor to restore the arrow cursor.

    Both these functions are static.

    Regards

  5. The following user says thank you to marcel for this useful post:

    bpetty (17th July 2007)

  6. #5
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Cursor not changing

    If anyone has any ideas, I am all ears. Thanks.
    Just a lame idea which might work. Add this before calling bool bRet = UpgradeUtils::PackageLogs();
    Qt Code:
    1. qApp->processEvents()
    To copy to clipboard, switch view to plain text mode 
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

Similar Threads

  1. Dynamically changing QFrame color
    By Doug Broadwell in forum Newbie
    Replies: 6
    Last Post: 16th October 2008, 08:22
  2. prob with changing QLineEdit background color
    By Ahmad in forum Qt Programming
    Replies: 2
    Last Post: 30th April 2007, 12:44
  3. Dynamically changing QLabel background colour
    By T4ng10r in forum Qt Programming
    Replies: 19
    Last Post: 19th April 2007, 12:47
  4. changing column width of QTableWidget
    By juliarg in forum Newbie
    Replies: 4
    Last Post: 22nd March 2007, 15:51
  5. changing the size of the tab width: QTabWidget
    By nikita in forum Qt Programming
    Replies: 2
    Last Post: 29th August 2006, 08:31

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.