Important: Please read the Qt Code of Conduct -

Changing Rectangle border color decline performance

  • I use GridView to build 3x3 rectangle block, and change the each border color when mouse hover entered, change back in exited.

    I notice the CPU utilization will increase when surfing on the Grid.

    If I simulate the border bar by 4 rectangle, and go to the same effect by change their color, then the CPU will go down apparently.

    Does someone have the same issue ?

    My environment is in Embedded Linux System, and use the frame buffer to display.

    Thanks : )

  • Are you on a very resource constrained system? Without having looked much at the code, I would guess that it spends the extra CPU simply because the entire rectangle is filled even if you only modify the border color. When borders are translucent, rounded or antialiased it often requires repainting the whole thing, so it generally just calls update() on the whole Item rect. It might be possible to special case this, but for now I think your fix sounds reasonable as it sounds like your bottle neck is simply the amount of pixels you can push and it might require managing each rect at a lower level.

Log in to reply