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. Changing text color for each tick in QCategoryAxis
Forum Updated to NodeBB v4.3 + New Features

Changing text color for each tick in QCategoryAxis

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

    Is there a way to assign a color for each tick in a QCategoryAxis?
    I know I can have a legend, but I prefer setting the colors on the axis to match the colors of the lines I have

    1 Reply Last reply
    0
    • RatzzR Offline
      RatzzR Offline
      Ratzz
      wrote on last edited by
      #2

      @Jonathan-Levanon

      Are you looking for setLinePen ?
      https://doc.qt.io/qt-5.10/qtcharts-customchart-example.html

      1 Reply Last reply
      0
      • Jonathan LevanonJ Offline
        Jonathan LevanonJ Offline
        Jonathan Levanon
        wrote on last edited by
        #3

        No. I want to change the color of the markers (text of the categories) themselves, not the ticks (sorry if that was unclear)

        1 Reply Last reply
        0
        • RatzzR Offline
          RatzzR Offline
          Ratzz
          wrote on last edited by
          #4

          @Jonathan-Levanon

          Did you mean axis label colors?

          1 Reply Last reply
          0
          • Jonathan LevanonJ Offline
            Jonathan LevanonJ Offline
            Jonathan Levanon
            wrote on last edited by Jonathan Levanon
            #5

            I think so...Notice that I want to set a different color for each label

            1 Reply Last reply
            0
            • RatzzR Offline
              RatzzR Offline
              Ratzz
              wrote on last edited by
              #6

              @Jonathan-Levanon

              If you know the count of the label u can use setLabelsBrush

              1 Reply Last reply
              0
              • Jonathan LevanonJ Offline
                Jonathan LevanonJ Offline
                Jonathan Levanon
                wrote on last edited by
                #7

                Did you mean

                axisY.setLabelsBrush(QBrush(Qt::red));
                

                But this sets the same color for all the labels.

                1 Reply Last reply
                0
                • RatzzR Offline
                  RatzzR Offline
                  Ratzz
                  wrote on last edited by Ratzz
                  #8
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • Jonathan LevanonJ Offline
                    Jonathan LevanonJ Offline
                    Jonathan Levanon
                    wrote on last edited by
                    #9

                    Answer - https://stackoverflow.com/questions/50156082/changing-text-color-for-each-label-in-qcategoryaxis/50156967#50156967

                    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