Results 1 to 8 of 8

Thread: dialog content is not painted

  1. #1
    Join Date
    Mar 2013
    Posts
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default dialog content is not painted

    Hello,
    my original problem was found in PyQt (http://stackoverflow.com/questions/1...-processevents), but it's almost the same when I rewrote in into C++.

    My goal is to show some dialog with label (something like "please wait" or whatever) while executing some other code in main thread. Main thread is important because of some error handlings (Qt Dialog with error message) etc later.
    Note: I have 2 connects to button.clicked because in pyqt version there were different behaviour (first dialog works fine, second one without label). In C++ version both dialogs aren't repainted.
    It seems Splash dialog is not repainted even if QApplication:rocessEvents(); is called. When I remove "delete splash;" line, it's repainted when main thread leaves MyWindow::handleButton method

    Thank you for any help or suggestion.

    Michal
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2012
    Location
    San Diego, California
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: dialog content is not painted

    What happens if you put another processEvents() after the sleep()? Or break up the 4-second delay into several shorter ones, with event processing between each?

  3. #3
    Join Date
    Mar 2013
    Posts
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: dialog content is not painted

    Quote Originally Posted by darenw View Post
    What happens if you put another processEvents() after the sleep()? Or break up the 4-second delay into several shorter ones, with event processing between each?
    Yes, it helps a bit (second processEvents() caused to paint on canvas). But I don't want to have that in handleButton() method (there should be custom code, maybe qt-independent). So I'm thinking about QTimer and call processEvents() in some interval.
    But there comes another problem - QTimer stops while handleButton() is executed.

  4. #4
    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: dialog content is not painted

    Quote Originally Posted by miso View Post
    Yes, it helps a bit (second processEvents() caused to paint on canvas). But I don't want to have that in handleButton() method (there should be custom code, maybe qt-independent).
    Run that code in a separate thread.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Mar 2013
    Posts
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: dialog content is not painted

    That would work (run custom code in separate thread in background) but I'd like to avoid that. This is how it worked before and I'd like to run it in main thread to avoid any deadlock/synchronisation dangerous.

    What I tried is to run processEvents() loop (with some sleep) in another thread to re-paint the dialog. It runs correctly but without any visible result.

  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: dialog content is not painted

    Quote Originally Posted by miso View Post
    That would work (run custom code in separate thread in background) but I'd like to avoid that.
    I'm sorry -- it's either threads or stalling the GUI thread while your custom code is running. Adding timers or whatever else that requires event processing will not help you in any way.

    What I tried is to run processEvents() loop (with some sleep) in another thread to re-paint the dialog. It runs correctly but without any visible result.
    Because it processes the other thread which has nothing to process.

    You simply have no choice. Either you run custom code in thread other than the GUI thread or your GUI thread will not respond during the time the custom code is ran.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Mar 2013
    Posts
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: dialog content is not painted

    I understand that. But because of QSplashScreen, I though it is somehow possible, isn't it?
    And I can't use QSplashScreen from Python (I use PyQt4) because I can't override mousePressEvent (it's protected) so click will close the widget.

  8. #8
    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: dialog content is not painted

    Quote Originally Posted by miso View Post
    I understand that. But because of QSplashScreen, I though it is somehow possible, isn't it?
    No, QSplashScreen works the same way. If you don't let it process events, it will not be updated.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QDialogButtonBox text not painted
    By kshi in forum Qt Programming
    Replies: 0
    Last Post: 8th January 2011, 00:41
  2. How to erase everything widget has painted?
    By TheNewGuy in forum Newbie
    Replies: 1
    Last Post: 12th December 2009, 07:23
  3. Widget not painted properly
    By qwakaw in forum Qt Programming
    Replies: 0
    Last Post: 11th November 2008, 11:30
  4. Tabs/Dialog with hidden/extendable content
    By dentharg in forum Qt Tools
    Replies: 6
    Last Post: 20th November 2007, 19:30

Tags for this Thread

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.