Results 1 to 7 of 7

Thread: qpushbutton not disabling properly

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: qpushbutton not disabling properly

    The shortest possible way to solve the problem is to add a call to QCoreApplication::processEvents().
    Qt Code:
    1. void RoboSearch::listFiles()
    2. {
    3. searchButton->setEnabled(false);
    4. // let the application process its events
    5. QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
    6. //code is searching through files, so it takes ~5s
    7. searchButton->setEnabled(true);
    8. }
    To copy to clipboard, switch view to plain text mode 
    5s is a long time for a GUI application to be frozen so you might want to call the same method every now and then during the search.
    J-P Nurmi

  2. The following user says thank you to jpn for this useful post:

    abrou (23rd February 2008)

  3. #2
    Join Date
    Jan 2008
    Location
    Vancouver, Canada
    Posts
    54
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qpushbutton not disabling properly

    Thank you very much!

    I am now trying apply it to another part of my code, where a pushbutton connection opens a dialog, but the dialog won't actually open until I close the original window.... hopefully I'm on the right track.

  4. #3
    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: qpushbutton not disabling properly

    Quote Originally Posted by abrou View Post
    I am now trying apply it to another part of my code, where a pushbutton connection opens a dialog, but the dialog won't actually open until I close the original window.... hopefully I'm on the right track.
    Hmm sorry, but it's hard to say anything without seeing relevant code.
    J-P Nurmi

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
  •  
Qt is a trademark of The Qt Company.