QWidget update events, but no visual update

Using Qt4.8 on Mint Linux 12, I implemented a simple window containing a QTableView to show the contents of the model. The model data is constantly updated (log messages), and the dataChanged() signal is emitted regularly (i.e., every 100 ms).

The problem that I see is stuttering visual updates in the table.

I set the event filter in a window that takes into account updateRequest -type events, which should trigger the widget redrawing (also on child widgets, i.e. tableView ). They enter with an average time of ~ 170 ms between them and a standard deviation of ~ 90 ms (which, I think, is quite large). However, the perceived rate of visual refresh is only two or three times per second, and I wonder why. It seems that not all updateRequest events cause a widget to be redrawn, or that the window system swallows visual updates.

As a second test, I made the window refresh itself by calling repaint or update every 100 ms. Using repaint , I saw a corresponding increase in events like updateRequest and a decrease in the standard deviation of spaces; with update number did not increase. However, in both cases, only a moderate increase in perceived update rate was observed.

Also: Is there a good method for measuring how often a widget is truly repainted without overloading the paintEvent handler? Maybe something from QTest ?


Update: I expanded the event filter to also catch paintEvent -type events. There is only a one-bit number of these events in comparison s> 1000 updateRequest .

+6
source share
2 answers

You need to measure the events dispatcher signals aboutToBlock() and awake() and measure the time between them with QElapsedTimer . The event manager instance for the current thread is returned by static QAbstractEventDispatcher::instance() .

If the event loop falls asleep for a very small part of your time measurement window, this means that too many things are happening in the GUI thread. You can calculate how long the event loop has slept, say, in the last second. If it is below 10%, you can expect slow updates and much more. Remember that update events are queued using Qt::LowEventPriority . They will be supplanted by standard signals in the queue and almost all other events.

+1
source

QApplication::compressEvent discards QEvent::UpdateRequest if it is no longer raw. Thus, even redrawing can immediately return without drawing if the event is discarded. You can check if your updateRequest events updateRequest thrown by overwriting compressEvent .

0
source

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


All Articles