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. How to stack QT Charts legend items vertical on bottom
Forum Updated to NodeBB v4.3 + New Features

How to stack QT Charts legend items vertical on bottom

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 519 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.
  • S Offline
    S Offline
    Saee1101
    wrote on last edited by Saee1101
    #1

    I need the legend items stacked one above another (vertically).
    When I do:

    QtCharts::QChart *m_pieChart; //member variable
    m_pieChart->legend()->setAlignment(Qt::AlignRight);
    

    I get this:
    alt text
    And setting the alignment to bottom moves the legend to the bottom:

    m_pieChart->legend()->setAlignment(Qt::AlignBottom);
    

    BUT the legend items are not stacked vertically anymore!
    alt text
    How to move the legend to the bottom AND have them stacked vertically?

    JonBJ 1 Reply Last reply
    0
    • S Saee1101

      I need the legend items stacked one above another (vertically).
      When I do:

      QtCharts::QChart *m_pieChart; //member variable
      m_pieChart->legend()->setAlignment(Qt::AlignRight);
      

      I get this:
      alt text
      And setting the alignment to bottom moves the legend to the bottom:

      m_pieChart->legend()->setAlignment(Qt::AlignBottom);
      

      BUT the legend items are not stacked vertically anymore!
      alt text
      How to move the legend to the bottom AND have them stacked vertically?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Saee1101
      At a guess you cannot, else something would be documented or work. It will offer a limited set of possible layouts for you to choose from.

      S 1 Reply Last reply
      0
      • JonBJ JonB

        @Saee1101
        At a guess you cannot, else something would be documented or work. It will offer a limited set of possible layouts for you to choose from.

        S Offline
        S Offline
        Saee1101
        wrote on last edited by
        #3

        @JonB
        I have to do this, suggest another way .
        please, help me .

        JonBJ 1 Reply Last reply
        0
        • S Saee1101

          @JonB
          I have to do this, suggest another way .
          please, help me .

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @Saee1101
          I see you have copied and pasted your question directly from stackoverflow, https://stackoverflow.com/questions/39243206/how-to-stack-qt-charts-legend-items-vertical-on-bottom, without mentioning this which is not helpful. That was asked 7 years ago. And did not attract any solutions. Suggestions included:

          Looking in the sources, starting here, it doesn't seem possible without modifying Qt's code

          [That is what I would have said.] And:

          I solved it differently using QPieSlice::setLabelVisible(true) on all slices.

          And:

          Why don't you use the detachFromChart()? Look at this

          Just saying "I have to do this" and "please help me" does not help. There is a reason why nobody posted a definite solution. So which of these did you try?

          S 1 Reply Last reply
          1
          • JonBJ JonB

            @Saee1101
            I see you have copied and pasted your question directly from stackoverflow, https://stackoverflow.com/questions/39243206/how-to-stack-qt-charts-legend-items-vertical-on-bottom, without mentioning this which is not helpful. That was asked 7 years ago. And did not attract any solutions. Suggestions included:

            Looking in the sources, starting here, it doesn't seem possible without modifying Qt's code

            [That is what I would have said.] And:

            I solved it differently using QPieSlice::setLabelVisible(true) on all slices.

            And:

            Why don't you use the detachFromChart()? Look at this

            Just saying "I have to do this" and "please help me" does not help. There is a reason why nobody posted a definite solution. So which of these did you try?

            S Offline
            S Offline
            Saee1101
            wrote on last edited by
            #5

            @JonB
            none . Actually, They aren't useful for me. I use :

              legend()->hide();
            

            and use label.
            thank you .

            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