Results 1 to 7 of 7

Thread: Want to refresh window without processEvents()

  1. #1
    Join Date
    Feb 2006
    Posts
    21
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Want to refresh window without processEvents()

    Whenever I use QApplication::processEvents() it allows the user to still do things in my application that I would rather them wait for the process to finish.

    Is there a way to refresh the window so it doesn't look like it's frozen without having to call QApplication::processEvents() ?

    If I have to use QApplication::processEvents() how can I deactivate everything until the process is done?

  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: Want to refresh window without processEvents()

    Maybe you could show a modal progress dialog during the process?
    A modal dialog would block the user in a sophisticated way from clicking elsewhere in the application.
    Sounds a bit harsh, but another option could be to disable the whole window during the process..

  3. #3
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Want to refresh window without processEvents()

    Hi jpn..

    Refreshing of a window or a page or else is a very fast executing operation...
    Modal Dialogs are used when the process takes some time and the progress of the operation is shown...

    Can this be a sol??? - > Capturing the snapshot of the entire window and then repainting the contents...
    This is just a suggestion.. It can be a wrong idea also...

    Kapil

  4. #4
    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: Want to refresh window without processEvents()

    Quote Originally Posted by Kapil
    Refreshing of a window or a page or else is a very fast executing operation...
    Refreshing of a window is not the lengthy process we are talking here..

    jnk5y: if you want your application to be responsive, you will have to let it to process it's events once in a while.
    So don't prevent your application from receiving it's events, rather block the user interaction somehow (modality, disabling..).

  5. #5
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Want to refresh window without processEvents()

    Quote Originally Posted by jpn
    Refreshing of a window is not the lengthy process we are talking here..
    Did i get the question wrong???

    Aahhh... what exactly it is??? Can u plz tel me...

    Kapil

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Want to refresh window without processEvents()

    QApplication::processEvents() taken an argument which can tell it not to process user input.

    If you want to refresh a window without refering to the event queue, call repaint().

    But you should really use a modal dialog here instead of doing any hacks. It can be as simple as:

    Qt Code:
    1. QDialog dlg(this);
    2. QLabel *l = new QLabel("Please wait", &dlg);
    3. dlg.exec();
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Feb 2006
    Posts
    21
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Want to refresh window without processEvents()

    I didn't realize that processEvents() took arguments.

    QEventLoop::AllEvents - is the default
    QEventLoop::ExcludeUserInputEvents - will allow the user to move the window and redraw it but will not let them press any buttons. I think this is what I will probably use unless there is a reason not to.

    Thanks for your help.

Similar Threads

  1. How to set Qt window transparent?
    By montylee in forum Qt Programming
    Replies: 17
    Last Post: 24th December 2013, 20:11
  2. QPainter and refresh window
    By Atikae in forum Qt Programming
    Replies: 3
    Last Post: 18th February 2009, 12:45
  3. Error: BadMatch --> what's it?
    By mattia in forum Newbie
    Replies: 4
    Last Post: 9th June 2008, 12:20
  4. Set a window as child at runtime
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 26th November 2007, 09:30
  5. Change shape of window / animate window
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 31st October 2007, 08:16

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.