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. How to remove blue selection color from qTableWidget?
Forum Updated to NodeBB v4.3 + New Features

How to remove blue selection color from qTableWidget?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 3.0k 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.
  • J Offline
    J Offline
    Jash_13
    wrote on last edited by
    #1

    UI has two tables in one tab. I want to add the functionality to show selection color of row that is blue only in one table at a time when the table got selected.

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

      Hi
      What platform are you on ?
      For me, its light grey when table dont have focus ?
      alt text

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

        @mrjj said in How to remove blue selection color from qTableWidget?:

        What platform are you on ?

        Windows, the style can not be changed here since it's windows default. He has to use another style or maybe via stylesheets.

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

        mrjjM 1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          @mrjj said in How to remove blue selection color from qTableWidget?:

          What platform are you on ?

          Windows, the style can not be changed here since it's windows default. He has to use another style or maybe via stylesheets.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Christian-Ehrlicher
          Hi
          Ok but he sounded like it was blue even when it lost focus which mine is not on windows 10.

          it can be changed with
          QTableWidget::item{ selection-background-color: red}

          but Im not sure how to style the "not having focus" color.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jash_13
            wrote on last edited by
            #5

            Hi @mrjj

            Thanks for your quick reply.

            It can be done with stylesheet but the problem with that is it will change the background color as the table has two background colors for filled rows and empty rows. I just want to remove the focus (blue highlight) from the table. And that can be done with setFocusPolicy() but it is not working.

            mrjjM 1 Reply Last reply
            0
            • J Jash_13

              Hi @mrjj

              Thanks for your quick reply.

              It can be done with stylesheet but the problem with that is it will change the background color as the table has two background colors for filled rows and empty rows. I just want to remove the focus (blue highlight) from the table. And that can be done with setFocusPolicy() but it is not working.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Jash_13
              Hi
              Ah yes, alternating colors must also be handled.

              Well setFocusPolicy should work as the normal fix is then not to allow it to get focus but in what way didnt that work for you ?

              I think maybe a delegate would work the best here as it could check if parent has focus and if not, simply skip drawing the selection state.

              1 Reply Last reply
              0
              • J Offline
                J Offline
                Jash_13
                wrote on last edited by
                #7

                Hello @mrjj

                Thanks for helping. The issue has been resolved with setFocusPolicy().

                1 Reply Last reply
                1

                • Login

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