Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. High CPU usage on QWidget's update()
Qt 6.11 is out! See what's new in the release blog

High CPU usage on QWidget's update()

Scheduled Pinned Locked Moved Solved Mobile and Embedded
6 Posts 3 Posters 3.1k 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.
  • R Offline
    R Offline
    Radim
    wrote on last edited by
    #1

    Hi, I'm trying to find out the source of a high CPU usage. I have already tried to comment out all code in the paintEvent() but it didn't helped. However the CPU usage dropped rapidly when I stopped calling the update() function.

    Some facts about the device/app

    • The app uses QWS
    • it is a full screen app

    Any idea how to optimize the code? What to check?

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

      Hi,

      How are you calling update and why ?

      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
      • R Offline
        R Offline
        Radim
        wrote on last edited by
        #3

        In our code we call update(QRect) multiple times to update each visualisation object.
        How does exactly work the update(QRect) in respect to paintEvent()? In our code we call update(QRect) multiple times. Will the paintEvent be called also multiple times or only once with the overall region including all rectangles?

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

          Calls to update should schedule a paint event to happen so it should not trigger an immediate repaint. However I don't know how it can optimize this if you call update repeatedly with rectangles of different sizes.

          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
          • R Radim

            In our code we call update(QRect) multiple times to update each visualisation object.
            How does exactly work the update(QRect) in respect to paintEvent()? In our code we call update(QRect) multiple times. Will the paintEvent be called also multiple times or only once with the overall region including all rectangles?

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @Radim, @SGaist
            Paint events are (ordinarily) compressed (as with keyboard events), so multiple calls to update generate a single paint event, provided the pending one was not consumed. Depending on the rect/region passed, the engine marks the first ancestral native widget's area as dirty and schedules a paint event. Ultimately, the dirty regions are united (geometrically) and a paint event is delivered when appropriate.

            @Radim,
            If you're painting your widget with opaque colors and respect the QRegion instance passed along with the paint event, you could most probably safely set either the Qt::WA_NoSystemBackground attribute, or depending on the case even the Qt::WA_OpaquePaintEvent attribute. This'd skip the background erasing done by Qt and you should be able to squeeze a bit more out of the widget.

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Radim
              wrote on last edited by
              #6

              After some testing it seems the bottle neck is the video memory throughput.

              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