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. Custom legend for chart?
Qt 6.11 is out! See what's new in the release blog

Custom legend for chart?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 741 Views 1 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.
  • J Offline
    J Offline
    Jon Levanon
    wrote on last edited by
    #1

    I have a QChart with multiple QLineSeries, that come from 2 sources - so each series get a color according to it's source. I want to have a legend only with the two sources but the native legend is based on all of the QLineSeries. Is there a way to custom the legend? Assign specific text values, or remove unwanted ones so only the 2 sources will remain?
    Thanks

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

      Hi
      You can get its legend
      QLegend *QChart::legend() const
      and then
      https://doc.qt.io/qt-5/qlegend.html#markers
      and you can then hide markers with
      https://doc.qt.io/qt-5/qlegendmarker.html#setVisible

      as far as i know its not possible to create a new legend as you cant assign it to the chart/series.

      1 Reply Last reply
      1
      • J Offline
        J Offline
        Jon Levanon
        wrote on last edited by
        #3

        Thanks, got it working!

        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