Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to force X11 to repaint?
Qt 6.11 is out! See what's new in the release blog

How to force X11 to repaint?

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 4 Posters 5.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vadi2
    wrote on last edited by
    #1

    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.

    jsulmJ 1 Reply Last reply
    0
    • V Vadi2

      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.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • V Offline
        V Offline
        Vadi2
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • V Offline
            V Offline
            Vadi2
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What kind of GUI are you creating ?

              How many widgets are there ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • V Offline
                V Offline
                Vadi2
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Do you really need to create them all on startup ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    Vadi2
                    wrote on last edited by
                    #9

                    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.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      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 ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      2
                      • V Offline
                        V Offline
                        Vadi2
                        wrote on last edited by
                        #11

                        In this case the player has marked all those screens to be loaded - by default, none are.

                        Still having troubles figuring out a good solution for this :|

                        A 1 Reply Last reply
                        0
                        • V Vadi2

                          In this case the player has marked all those screens to be loaded - by default, none are.

                          Still having troubles figuring out a good solution for this :|

                          A Offline
                          A Offline
                          ambershark
                          wrote on last edited by ambershark
                          #12

                          @Vadi2 Typically this is what applications use a splash screen for. It's so you can load your gui while showing a progress bar and a splash screen. This is acceptable to users since they can see something is happening and it is better for you since your GUI will be fast once it's all built and loaded.

                          Even GIMP does it in linux. Although most apps don't need to any more since CPUs have gotten so fast.

                          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                          1 Reply Last reply
                          0
                          • V Offline
                            V Offline
                            Vadi2
                            wrote on last edited by
                            #13

                            You have an idea with the splash screen. I do have one before this, but it is possible there will be user input, it's not shown after - I think I could make something work here.

                            A 1 Reply Last reply
                            0
                            • V Vadi2

                              You have an idea with the splash screen. I do have one before this, but it is possible there will be user input, it's not shown after - I think I could make something work here.

                              A Offline
                              A Offline
                              ambershark
                              wrote on last edited by
                              #14

                              @Vadi2 Yea so you're basically just hiding the interface as you build it, while showing the splash screen (sometimes with a progress bar), and then when it's ready you hide the splash and show the interface. That show should be fast since it doesn't create anything.

                              My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved