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

Change color of headers

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.0k 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 1 Feb 2023, 14:49 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.

    J 1 Reply Last reply 1 Feb 2023, 14:53
    0
    • V Vlad02
      1 Feb 2023, 14:49

      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.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 1 Feb 2023, 14:53 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 Feb 2023, 15:23
      1
      • J Offline
        J Offline
        JoeCFD
        wrote on 1 Feb 2023, 14:58 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 Feb 2023, 15:36
        1
        • J jsulm
          1 Feb 2023, 14:53

          @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 1 Feb 2023, 15:23 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
          • J JoeCFD
            1 Feb 2023, 14:58

            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 1 Feb 2023, 15:36 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

            1/5

            1 Feb 2023, 14:49

            • Login

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