Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTreeWidgetItem Icon disappears in QT6
Forum Updated to NodeBB v4.3 + New Features

QTreeWidgetItem Icon disappears in QT6

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 283 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    WWebber
    wrote on last edited by WWebber
    #1

    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.

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Please provide a minimal, compileable example of the problem.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      W 1 Reply Last reply
      1
      • H Offline
        H Offline
        Helmut.Jakoby
        wrote on last edited by
        #3

        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.

        https://www.globalobjects.de/

        1 Reply Last reply
        0
        • W Offline
          W Offline
          WWebber
          wrote on last edited by
          #4

          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??

          1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            Please provide a minimal, compileable example of the problem.

            W Offline
            W Offline
            WWebber
            wrote on last edited by
            #5

            @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.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved