Qt custom widget updates big overhead

We are trying to use Qt 4.8.5 for some of the embedded Linux-based devices in our company. I use Qt without an X server. I need to display the measured data and update it very often (20-30 frames per second, but only a small part of the widget). The system is based on ARM, 400 MHz, does not have a GPU and FPU. I subclassed QWidget and redefined paintEvent (). I have WA_OpaquePaintEvent and WA_StaticContents set. For testing, my drawing event is empty, and I call the update () function of the widget form with a timer set to 50 ms. My problem is that an empty update is 30% of the CPU. The amount depends on the update area, so I think that QT can redraw something in the background. I read a lot of posts, but I can not find a solution to the problem. If I comment on the call to update, the processor load will drop to ~ 1% (even if I create a sine in the timer to test the widget, which should be much more complicated than an empty function call). My widget is rectangular, not transparent, and I want to process the entire drawing procedure from the paint event.

Is it possible to reduce this overhead and process the entire drawing process yourself?

+4
source share
1 answer

"Empty update" is not empty - it redraws the entire window :)

Have you read below?

To quickly update custom widgets with simple background colors, such as real-time widgets or graphic widgets, it’s best to determine the appropriate background color (using setBackgroundRole () with the QPalette :: Window role), set the autoFillBackground property, and only implement the necessary drawing functions in widget paintEvent ().

You should also use QWidget::scroll() , since inside it scans the backup storage in the window and is much more efficient than repainting the whole thing if only a tiny fragment is added to it.

+1
source

Source: https://habr.com/ru/post/1495195/


All Articles