Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
6.2.3
-
None
-
CPython 3.10 x64
PySide 6.2.3
Windows 10 x64
Description
I'm developing an application that does data acquisition and plotting, with a target refresh rate of 60FPS.
I use a QTreeWidget with 4 columns to hold the signals information. Depending on each signal's current value, the associated QTreeWidgetItem needs to update the font color and background. This update is done only if the QTreeWidgetItem is visible.
There is a clear freeze when the updates occur (32 visible signals in the GIF), and I've determined that the freeze is caused by this code:
if new_background_color is None: if self._background_color != self.background(0).color(): self.setBackground(0, self._background_color) self.setBackground(1, self._background_color) self.setBackground(2, self._background_color) self.setBackground(3, self._background_color) else: if new_background_color != self.background(0).color(): self.setBackground(0, new_background_color) self.setBackground(1, new_background_color) self.setBackground(2, new_background_color) self.setBackground(3, new_background_color) if new_font_color is None: if self.signal.color != self.foreground(0).color(): self.setForeground(0, self.signal.color) self.setForeground(1, self.signal.color) self.setForeground(2, self.signal.color) self.setForeground(3, self.signal.color) else: if new_font_color != self.foreground(0).color(): self.setForeground(0, new_font_color) self.setForeground(1, new_font_color) self.setForeground(2, new_font_color) self.setForeground(3, new_font_color)
If I comment out that snippet each update of the QTreeWidgetitem (setting the text in column 1) takes ~6us. When the code is enabled, each time the background or foreground is changed takes 1.6ms per item. With a small visible count of 32 items this caused a clear freeze in the GUI (see the attached GIFs).