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. Change color of headers
Qt 6.11 is out! See what's new in the release blog

Change color of headers

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 2.4k Views
  • 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.
  • V Offline
    V Offline
    Vlad02
    wrote on last edited by
    #1

    Hi everybody! I work with QTableWidget and ran into a problem, how to change the style of the vertical header? I want to get something like this:
    0409dd3f-64d1-47d6-93ee-437ee1df3672-image.png
    I have interest for column with green text. Can I change the style of vertical header on such as in the first column or no? If yes, how? I tried set StyleSheet, but it's not work how I need.

    jsulmJ 1 Reply Last reply
    0
    • V Vlad02

      Hi everybody! I work with QTableWidget and ran into a problem, how to change the style of the vertical header? I want to get something like this:
      0409dd3f-64d1-47d6-93ee-437ee1df3672-image.png
      I have interest for column with green text. Can I change the style of vertical header on such as in the first column or no? If yes, how? I tried set StyleSheet, but it's not work how I need.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Vlad02 said in Change color of headers:

      I tried set StyleSheet, but it's not work how I need

      Please show how.
      Also, is it a QTableWidget or QTableView?
      You need to set style sheet on vertical header.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      V 1 Reply Last reply
      1
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #3

        as jsulm said, set style sheet to vertical header
        https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qheaderview

        V 1 Reply Last reply
        1
        • jsulmJ jsulm

          @Vlad02 said in Change color of headers:

          I tried set StyleSheet, but it's not work how I need

          Please show how.
          Also, is it a QTableWidget or QTableView?
          You need to set style sheet on vertical header.

          V Offline
          V Offline
          Vlad02
          wrote on last edited by
          #4

          @jsulm Set StyleSheet:

              QHeaderView *header = ui->memoryTable->verticalHeader();
              header->setStyleSheet("background-color: black;"
                                    "color: green;"
                                    "border: none;");
              ui->memoryTable->setVerticalHeader(header);
              ui->memoryTable->verticalHeader()->setVisible(true);
          

          And I use QTableWidget. Color of text changed, but I get next:
          d340fffa-b366-447d-9632-86ced229750b-image.png

          1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

            as jsulm said, set style sheet to vertical header
            https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qheaderview

            V Offline
            V Offline
            Vlad02
            wrote on last edited by
            #5

            @JoeCFD Oh, that is it. I did not think that it is also necessary to specify the section. Now it worked, thanks a lot!

            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