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. TableView Header problem
Forum Updated to NodeBB v4.3 + New Features

TableView Header problem

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 2 Posters 2.1k 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.
  • B Offline
    B Offline
    BrianE
    wrote on last edited by
    #1

    Qt 5.6. All working OK except for one small thing. In the headerData function I have:

    if (role == Qt::BackgroundRole) return QBrush(Qt::lightGray);
    

    but it doesn't happen. Everything else works fine. Anyone know why?

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

      Hi,

      What do you mean by it doesn't happen ? The role is never Qt::BackgroundRole ? Or your brush has no effect ?

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

        I quote from QT 5.6 QHeaderView Class, section on appearance:

        "Not all ItemDataRoles will have an effect on a QHeaderView. If you need to draw other roles, you can subclass QHeaderView and reimplement paintEvent(). QHeaderView respects the following item data roles: TextAlignmentRole, DisplayRole, FontRole, DecorationRole, ForegroundRole, and BackgroundRole."

        So, BackgroundRole should give background colour to the headerview but mine stay white. I can change the font and I can change the foreground colour (text colour).

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

          What OS are you running ?

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

            Windows 10

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

              I don't have such a machine at hand. Can you test that again using the fusion style ? You have an example here

              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
              • B Offline
                B Offline
                BrianE
                wrote on last edited by
                #7

                Did that. It works! What is going on? Before I scream and pull what little hair I have left out could you offer a quick explanation. Other stuff looks different, too.

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

                  Setting the background role will modify the QPalette used for the painting and from the QPalette documentation, styles using native theme engines may not use the palette for all drawings.

                  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
                  • B Offline
                    B Offline
                    BrianE
                    wrote on last edited by
                    #9

                    OK. Thanks for that. Sanity has returned and I'll now go away and investigate palettes and styles and stuff.

                    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