How to force X11 to repaint?



  • QCoreApplication::processEvents() on Ubuntu is not ensuring that the window contents are drawn - I'm guessing because X11 is async. Is there way to make sure the window is refreshed besides dodgy timers?

    I tried QCoreApplication::flush() with no effect as well. Right now, I have to use a dodgy timer 50ms workaround before continuing and that won't fly with X11's networking capabilities.


  • Moderators

    @Vadi2 Why do you need to repaint? Are you blocking the event loop?



  • Yes, I'm doing a lot of work on the main thread.


  • Lifetime Qt Champion

    Hi,

    It sounds like you should consider delegating some stuff to a secondary thread.



  • The work that I am doing actually involves creation of the GUI - it just takes a really long while to do everything. There is a lot of QWidgets and QLabels involved.

    So there is no way to wait until X11 syncs to continue?


  • Lifetime Qt Champion

    What kind of GUI are you creating ?

    How many widgets are there ?



  • I'm not sure how to count them. Here's how it looks like when I have a 0ms timer before I start doing the bulk of creation though:

    https://transfer.sh/14dDdv/Kazam_screencast_00013.mp4

    And here's how it looks like when I put in an artificial 50ms delay:

    https://transfer.sh/mrSDy/Kazam_screencast_00014.mp4

    The theoretical problem is that since X11 is async and allows for networking, and even though it is on its way out the door, there potentially could be a networked case where the 50ms delay is not enough and the user would see the behaviour in the first video. For this I'd like to force Qt to repaint before doing the bulk of creation.


  • Lifetime Qt Champion

    Do you really need to create them all on startup ?



  • Yeah.

    I'm thinking of adding some of a loading widget to cover the entire screen while Qt does stuff in the background, though I realise now it won't work as it's all on one thread.


  • Lifetime Qt Champion

    But why all of them ? Shouldn't you use lazy loading so that screens that a player doesn't use don't wastes memory and cpu cycles ?


Log in to reply