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. Fusion style QTableView leaving shadow highlight only on single cell
Forum Updated to NodeBB v4.3 + New Features

Fusion style QTableView leaving shadow highlight only on single cell

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 3 Posters 834 Views 1 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.
  • C Offline
    C Offline
    cancech
    wrote on last edited by
    #1

    I'm creating a QTableView and configured it such that the selection behavior is "SelectRows".

    ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
    

    And this works great, doing exactly what I want. I'm playing around with theming and I'm liking the look of "fusion" and with this the selection behavior still work as expected - select a single cell and the whole row is selected. Without the fusion theme "selecting away" deselects the whole row. However, with the fusion theme when I "select away" a "shadow highlight" is left behind, which only highlights the specific cell that had been clicked.

    table.png

    In this situation the table view is larger than what the rows can fill, so by "select away" I mean select into the unfilled table view area. It would appear that even though there is a "shadow highlight" on the cell, the row (nor the cell) is considered selected, so I would expect that the highlight would be completely cleared. Is there any way in which I can control/force that?

    Note: I'm using Qt 6.7

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      On which OS are you working ?
      Can you provide a minimal compilable exemple showing this behavior ?

      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
      • C Offline
        C Offline
        cancech
        wrote on last edited by
        #3

        Thanks for the prompt reply!

        I'm working in Windows 11 and I've created a minimal (compilable) example that I've pushed to GitHub showing the issue that I'm running into.

        Locally my system is in a dark theme with purple as the accent color.

        68f481aa-5eae-4868-841c-c04219c92879-image.png

        Christian EhrlicherC 1 Reply Last reply
        0
        • C cancech

          Thanks for the prompt reply!

          I'm working in Windows 11 and I've created a minimal (compilable) example that I've pushed to GitHub showing the issue that I'm running into.

          Locally my system is in a dark theme with purple as the accent color.

          68f481aa-5eae-4868-841c-c04219c92879-image.png

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

          Use the windowsvista style instead to see if the problem persist.

          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
          • C Offline
            C Offline
            cancech
            wrote on last edited by
            #5

            Ultimate the same thing can be seen with the windowsvista style, just not as pronounced. With the windowsvista the cell retains a dashed line.

            1846109f-96b4-4bcd-9b49-4420684af02e-image.png

            With the windowsvista style I feel that it's more clearly noted that this is "where you last clicked" whereas the fusion style makes it seem like it's actually highlighted.

            Is this behavior something that can be turned off?

            Christian EhrlicherC 1 Reply Last reply
            0
            • C cancech

              Ultimate the same thing can be seen with the windowsvista style, just not as pronounced. With the windowsvista the cell retains a dashed line.

              1846109f-96b4-4bcd-9b49-4420684af02e-image.png

              With the windowsvista style I feel that it's more clearly noted that this is "where you last clicked" whereas the fusion style makes it seem like it's actually highlighted.

              Is this behavior something that can be turned off?

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

              @cancech Please simplify your example - no need for a model or extra mainwindow. The less classes the less to debug here.

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

              C 1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                @cancech Please simplify your example - no need for a model or extra mainwindow. The less classes the less to debug here.

                C Offline
                C Offline
                cancech
                wrote on last edited by
                #7

                @Christian-Ehrlicher I'm not sure how to simplify my example. I don't see how to add data to the QTableView without creating my own model and I believe that mainwindow.h, mainwindow.cpp, and mainwindow.ui are all three needed. Short or removing the mainwindow.ui and reproducing the layout in code that is.

                Christian EhrlicherC 1 Reply Last reply
                0
                • C cancech

                  @Christian-Ehrlicher I'm not sure how to simplify my example. I don't see how to add data to the QTableView without creating my own model and I believe that mainwindow.h, mainwindow.cpp, and mainwindow.ui are all three needed. Short or removing the mainwindow.ui and reproducing the layout in code that is.

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

                  @cancech simply create a tableview, add a stringlist model and show it. No mainwindow or other stuff needed.

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

                  C 1 Reply Last reply
                  0
                  • Christian EhrlicherC Christian Ehrlicher

                    @cancech simply create a tableview, add a stringlist model and show it. No mainwindow or other stuff needed.

                    C Offline
                    C Offline
                    cancech
                    wrote on last edited by
                    #9

                    @Christian-Ehrlicher Got it! I've updated the example to remove the unnecessary pieces.

                    Christian EhrlicherC 1 Reply Last reply
                    0
                    • C cancech

                      @Christian-Ehrlicher Got it! I've updated the example to remove the unnecessary pieces.

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

                      Ok, now I know what you mean. This is the marking for the currently index. There is a difference between selected indexes and current index. That's the same as when you select a file in windows explorer and then click on a blank area - the previously selected row is still painted somewhat different.

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

                      C 1 Reply Last reply
                      1
                      • Christian EhrlicherC Christian Ehrlicher

                        Ok, now I know what you mean. This is the marking for the currently index. There is a difference between selected indexes and current index. That's the same as when you select a file in windows explorer and then click on a blank area - the previously selected row is still painted somewhat different.

                        C Offline
                        C Offline
                        cancech
                        wrote on last edited by
                        #11

                        @Christian-Ehrlicher Ahh, I see. So it's there to indicate "if you press the arrow keys, there is where you'll be starting from". Considering that I'm using whole row selection, shouldn't the whole row be the index then? I would presume that pressing the left/right arrows wouldn't really do anything

                        Christian EhrlicherC 1 Reply Last reply
                        0
                        • C cancech

                          @Christian-Ehrlicher Ahh, I see. So it's there to indicate "if you press the arrow keys, there is where you'll be starting from". Considering that I'm using whole row selection, shouldn't the whole row be the index then? I would presume that pressing the left/right arrows wouldn't really do anything

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

                          @cancech In Qt there is only one 'current index' possible. And you can't change this anywhere - you can only change the selection behavior.

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

                          C 1 Reply Last reply
                          0
                          • Christian EhrlicherC Christian Ehrlicher

                            @cancech In Qt there is only one 'current index' possible. And you can't change this anywhere - you can only change the selection behavior.

                            C Offline
                            C Offline
                            cancech
                            wrote on last edited by
                            #13

                            @Christian-Ehrlicher Gotcha, thanks so much for all the help and figuring out what's going on!

                            Christian EhrlicherC 1 Reply Last reply
                            0
                            • C cancech

                              @Christian-Ehrlicher Gotcha, thanks so much for all the help and figuring out what's going on!

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

                              @cancech You might reset the current index flag during painting by overriding https://doc.qt.io/qt-6/qabstractitemview.html#initViewItemOption

                              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
                              1
                              • C cancech has marked this topic as solved on

                              • Login

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