Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to completely remove margins/spacing with QML ChartView
Qt 6.11 is out! See what's new in the release blog

How to completely remove margins/spacing with QML ChartView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 3.6k 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.
  • O Offline
    O Offline
    Obi-Wan
    wrote on last edited by
    #1

    The question is the same as in this thread:

    Re: How to remove spacings? QML ChartView.

    @MikhailG posted the same question on StackOverflow and apparently this answer solves it:

    Possible solution 1: QMargins property designates the minimum area around the plotting area. Try filling this remaining padding by adjusting the child (plot) itself.

    But what does that mean? I've tried setting the size of the plotArea, but it's read only.

    I wanted to comment on the answer in SO, but I do not have enough reuptation to do so. If anyone else wants to do so and page @MIkhailG there, feel free :)

    Any ideas?

    1 Reply Last reply
    0
    • O Offline
      O Offline
      Obi-Wan
      wrote on last edited by
      #2

      I found a hacky solution and posted it on SO to get a response from @MikhailG there, and he updated his answer.

      My solution in short:

      ChartView
      {
          x: -10
          y: -10
      
          width: parent.width + 20
          height: parent.height + 20
      }
      

      In addition to setting the margins to 0 and having the legend and the axes not be visible.

      See this link for the updated answer on SO.

      1 Reply Last reply
      2
      • 6thC6 Offline
        6thC6 Offline
        6thC
        wrote on last edited by
        #3

        It'd be great if this wasn't necessary... thanks for sharing - that's something that's bugging me right now, just not high priority yet.

        I also wish we could get at the QChart* / Chart item from that ChartView there... I haven't found a way except pass a LineSeries ref to C++, QLineSeries* ptr->chart(); is just a bit annoying.

        Anyhow - charts that I didn't have to handcraft - they are working very well so far for me.

        Re: the legend: I'm was pleased with how it hides the legend for a series's visible set to false. That was nice to not have to work for that.

        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