Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Selection highlight is a thin blue bar at the left of the cell.
Qt 6.12 LTS is out! See what's new in the release blog

Selection highlight is a thin blue bar at the left of the cell.

Scheduled Pinned Locked Moved Unsolved Qt for Python
15 Posts 5 Posters 477 Views 3 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.
  • J Offline
    J Offline
    Jim G
    wrote last edited by
    #4

    The flags() question was interesting, but the default is ItemIsSelectable|ItemIsEnabled, and implementing flags() returning those values had no effect.

    I tried some sample code using QTableWidget, and that works correctly. I then made sure my code sets all the same attributes on the view and the model, with no effect. I'm stumped. I guess I'm going to have to reimplement my code with QTableWidget and see what happens.

    More later...

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SimonSchroeder
      wrote last edited by
      #5

      You data method only returns something for the few roles you have specified. Otherwise you are returning None. Try instead to return QAbstractItemModel.data(...) (I don't know Python and can't tell you how to exactly write that). This might solve your problem, but I'm not sure.

      SGaistS 1 Reply Last reply
      0
      • S SimonSchroeder

        You data method only returns something for the few roles you have specified. Otherwise you are returning None. Try instead to return QAbstractItemModel.data(...) (I don't know Python and can't tell you how to exactly write that). This might solve your problem, but I'm not sure.

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote last edited by
        #6

        @SimonSchroeder said in Selection highlight is a thin blue bar at the left of the cell.:

        You data method only returns something for the few roles you have specified. Otherwise you are returning None. Try instead to return QAbstractItemModel.data(...) (I don't know Python and can't tell you how to exactly write that). This might solve your problem, but I'm not sure.

            return super().data(index, role)
        

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jim G
          wrote last edited by
          #7

          In C++ you return a default QVariant() for default behavior. In PySide6 this maps to None, and QVariant is not even defined or available for use. Also, in PySide6 QAbstractItemModel.data() is virtual with no default implementation.

          Using return super().data(index,role) raises NotImplementedError as expected

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jim G
            wrote last edited by Jim G
            #8

            OK, I think I found a bug. I closely examined some sample code I found that uses a QStandardItemModel, and displays selection highlights correctly. Here's a screenshot:

            2026-10-09_12-50-31.PNG

            Other than the change of model class, the only other difference I could find was that in the sample code there is this:

                    # Alternating row colors for data density scannability
                    self.table_view.setAlternatingRowColors(True)
            

            So I tried adding that to my code, and it fixed the issue:

            2026-10-09_12-53-11.PNG

            Bug?

            Also note that in my earlier screenshot showing the problem, there is already alternate row highlighting which is unexpected as the default for alternatingRowColors is False. Something's amiss here.

            Christian EhrlicherC 1 Reply Last reply
            0
            • J Jim G

              OK, I think I found a bug. I closely examined some sample code I found that uses a QStandardItemModel, and displays selection highlights correctly. Here's a screenshot:

              2026-10-09_12-50-31.PNG

              Other than the change of model class, the only other difference I could find was that in the sample code there is this:

                      # Alternating row colors for data density scannability
                      self.table_view.setAlternatingRowColors(True)
              

              So I tried adding that to my code, and it fixed the issue:

              2026-10-09_12-53-11.PNG

              Bug?

              Also note that in my earlier screenshot showing the problem, there is already alternate row highlighting which is unexpected as the default for alternatingRowColors is False. Something's amiss here.

              Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote last edited by Christian Ehrlicher
              #9

              @Jim-G said in Selection highlight is a thin blue bar at the left of the cell.:

              Bug?

              No, it's the default WinUI 3 style.

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

              J 1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                @Jim-G said in Selection highlight is a thin blue bar at the left of the cell.:

                Bug?

                No, it's the default WinUI 3 style.

                J Offline
                J Offline
                Jim G
                wrote last edited by
                #10

                @Christian-Ehrlicher said in Selection highlight is a thin blue bar at the left of the cell.:

                @Jim-G said in Selection highlight is a thin blue bar at the left of the cell.:

                Bug?

                No, it's the default WinUI 3 style. Look into your explorer to see that the highlight is gray.

                I'm not following. I think we're talking about two different things. I can reproduce the issue using the sample code only.

                Here's the UI including self.table_view.setAlternatingRowColors(True) and line 4 selected:

                2026-10-09_12-50-31.PNG

                And now with that single line commented out and line 3 selected:

                2026-10-09_13-06-02.PNG

                Notice the "selection" highlight in the second screenshot is just a thin blue line at the left of each cell.

                It is unexpected that displaying the correct highlighting would involve the setting of alternatingRowColors.

                Christian EhrlicherC 1 Reply Last reply
                0
                • J Jim G

                  @Christian-Ehrlicher said in Selection highlight is a thin blue bar at the left of the cell.:

                  @Jim-G said in Selection highlight is a thin blue bar at the left of the cell.:

                  Bug?

                  No, it's the default WinUI 3 style. Look into your explorer to see that the highlight is gray.

                  I'm not following. I think we're talking about two different things. I can reproduce the issue using the sample code only.

                  Here's the UI including self.table_view.setAlternatingRowColors(True) and line 4 selected:

                  2026-10-09_12-50-31.PNG

                  And now with that single line commented out and line 3 selected:

                  2026-10-09_13-06-02.PNG

                  Notice the "selection" highlight in the second screenshot is just a thin blue line at the left of each cell.

                  It is unexpected that displaying the correct highlighting would involve the setting of alternatingRowColors.

                  Christian EhrlicherC Online
                  Christian EhrlicherC Online
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote last edited by
                  #11

                  @Jim-G said in Selection highlight is a thin blue bar at the left of the cell.:

                  Notice the "selection" highlight in the second screenshot is just a thin blue line at the left of each cell.

                  And that's the correct winui3 style.
                  3d371abe-a5a4-4328-ae54-9f9e0395d0d7-grafik.png

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

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    Jim G
                    wrote last edited by Jim G
                    #12

                    So why does setting alternatingRowColors cause the change in highlight? Is that a bug?

                    I'm not trying to be difficult. I'm still learning Qt/PySide6 (excellent tools IMO) and am puzzled by the need to set alternatingRowColors just to get the expected highlight behavior.

                    Christian EhrlicherC S 2 Replies Last reply
                    0
                    • J Offline
                      J Offline
                      Jim G
                      wrote last edited by
                      #13

                      Also, what I see differs markedly from the example of winui 3 selection you cite. My selection indicators are only 2 pixels wide and jammed up against the left side of the text with no intervening space... actually they overlap (under) the leftmost pixel column of the text.

                      1 Reply Last reply
                      0
                      • J Jim G

                        So why does setting alternatingRowColors cause the change in highlight? Is that a bug?

                        I'm not trying to be difficult. I'm still learning Qt/PySide6 (excellent tools IMO) and am puzzled by the need to set alternatingRowColors just to get the expected highlight behavior.

                        Christian EhrlicherC Online
                        Christian EhrlicherC Online
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote last edited by
                        #14

                        @Jim-G said in Selection highlight is a thin blue bar at the left of the cell.:

                        So why does setting alternatingRowColors cause the change in highlight? Is that a bug?

                        The WinUI3 style has no information about alternating row colors so this is the solution for this.

                        med up against the left side of the text with no intervening space

                        This will be fixed

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

                        1 Reply Last reply
                        0
                        • J Jim G

                          So why does setting alternatingRowColors cause the change in highlight? Is that a bug?

                          I'm not trying to be difficult. I'm still learning Qt/PySide6 (excellent tools IMO) and am puzzled by the need to set alternatingRowColors just to get the expected highlight behavior.

                          S Offline
                          S Offline
                          SimonSchroeder
                          wrote last edited by
                          #15

                          @Jim-G said in Selection highlight is a thin blue bar at the left of the cell.:

                          So why does setting alternatingRowColors cause the change in highlight?

                          Qt tries to use the OS default widgets first. Alternating row colors is not supported by the OS directly. So, Qt will draw it from scratch and usually tries to mimic the OS look. Seems like it did not get updated, yet.

                          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
                          • Unsolved