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. Table view: custom alternate row colors?
Forum Updated to NodeBB v4.3 + New Features

Table view: custom alternate row colors?

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

    how do i get something like this?

    0_1558403894948_Screen Shot 2019-05-20 at 6.57.18 PM.png
    when i try to use a style sheet, like this:

    tracksList->setStyleSheet("alternate-background-color: #bfffbf; background-color: #deffde;");
    

    it colorizes the ENTIRE background including the header (sort-column) bar, and gives me non-platform scroll bars. this is supposed to be a mac (with mac scroll bars):

    0_1558404135796_Screen Shot 2019-05-20 at 7.01.08 PM.png

    I just want the table view background color set, not the sort-column header nor the scroll bars. how?

    1 Reply Last reply
    1
    • D Offline
      D Offline
      davecotter
      wrote on last edited by
      #6

      magic!

      0_1558543364465_Screen Shot 2019-05-22 at 9.20.54 AM.png

      1 Reply Last reply
      1
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by VRonin
        #2

        try using the item scope tracksList->setStyleSheet("QTableView::item:alternate { background-color: #bfffbf; } QTableView::item { background-color: #deffde; }");

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        8
        • D Offline
          D Offline
          davecotter
          wrote on last edited by
          #3

          holy cats you guys! that worked!

          0_1558455802162_Screen Shot 2019-05-21 at 9.22.59 AM.png

          1 Reply Last reply
          0
          • D Offline
            D Offline
            davecotter
            wrote on last edited by davecotter
            #4

            okay so the final part is: now that i've got the BG colors lookin sweet, suddenly the SELECTION color is all wiggy. ie: without setting the alt-rows colors, selection looks like this:

            0_1558539378861_Screen Shot 2019-05-22 at 8.33.01 AM.png

            but WITH the alt-rows colors set, it looks like this?

            0_1558539406244_Screen Shot 2019-05-22 at 8.34.50 AM.png

            ie: no actual selection hilight, but the text does turns white?

            I actually need it to have that very dark selection look. I don't see in the doc on style sheets how to accomplish that?

            Gojir4G 1 Reply Last reply
            0
            • D davecotter

              okay so the final part is: now that i've got the BG colors lookin sweet, suddenly the SELECTION color is all wiggy. ie: without setting the alt-rows colors, selection looks like this:

              0_1558539378861_Screen Shot 2019-05-22 at 8.33.01 AM.png

              but WITH the alt-rows colors set, it looks like this?

              0_1558539406244_Screen Shot 2019-05-22 at 8.34.50 AM.png

              ie: no actual selection hilight, but the text does turns white?

              I actually need it to have that very dark selection look. I don't see in the doc on style sheets how to accomplish that?

              Gojir4G Offline
              Gojir4G Offline
              Gojir4
              wrote on last edited by
              #5

              @davecotter Hi,
              Use palette instead of stylesheet so you will not have the issue with selection.

              QPalette p = tracksList.palette();
              p.setColor(QPalette::Base, color1);
              p.setColor(QPalette::AlternateBase, color2);
              tracksList.setPalette(p);
              
              1 Reply Last reply
              5
              • D Offline
                D Offline
                davecotter
                wrote on last edited by
                #6

                magic!

                0_1558543364465_Screen Shot 2019-05-22 at 9.20.54 AM.png

                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