QTreeWidgetItem Icon disappears in QT6
-
One and the same code behaves different in QT5 and 6,
I use a QTreeWidgetItem with checkboxes and icons.
When I set the background color of the item, the icon disappears with QT6. In QT5 it stays visible. How can I fix this?
Addon-Info: When I select the item, the icon appears and when I unselect it disappears again. -
Please provide a minimal, compileable example of the problem.
-
Hello @Webber,
Just to note, if you create your UI files with QtDesigner, you should be aware that the resulting UI files from the QtDesigner in QT5 are not the same as those from QT6.
While there are no errors, the resulting UI may look different because the QtDesigner in QT6 uses different markup in the UI file, which affects the display.
As an example from version 5:
...
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
...
From version 6
...-
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
...This doesn't cause any errors, but it does affect the view if, for example, the UI file from QT6 is processed with version QT5.
-
The QTreeWidgetItem is not created from an UI file but from code. Here's what I do - nothing special:
item->setIcon(0, myIcon);
QBrush brush;
brush.setStyle( Qt::SolidPattern);
brush.setColor( QColor("yellow") );
item->setBackGround( 0, brush );if I use 'Qt::Dense4Pattern' instead of 'SolidPattern', the background color affects the icon display?!?
It looks like the background color is applied on top of the icon?? -
Please provide a minimal, compileable example of the problem.
@Christian-Ehrlicher said in QTreeWidgetItem Icon disappears in QT6:
Please provide a minimal, compileable example of the problem.
Here's an example code.: QtTreeViewTest.zip
The issue comes up with my own checkboxes. Again, under QT5 everything was fine.