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

Resize QChartView automatically

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 2.9k Views 2 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.
  • michalt38M Offline
    michalt38M Offline
    michalt38
    wrote on last edited by michalt38
    #1

    I have a QFrame transormed from a Horizontal Layout. I'm using it for QChartView:

    QLineSeries * series = new QLineSeries();
    
    QChart * chart = new QChart();
    chart ->legend()->hide();
    chart ->addSeries(series);
    chart ->createDefaultAxes();
    chart ->setTitle("Chart");
    
    QChartView * chartView = new QChartView(chart);
    chartView ->setRenderHint(QPainter::Antialiasing);
    chartView ->setParent(ui->chart);
    

    The problem is that the chart is not resizing when I resize a window. It resizes only using chartView->resize(). centralwidget is set to Vertical Layout. How can I set the QChartView to resize automatically to fit the content?

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

      Hi,

      Please show the complete widget setup with the QFrame.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • michalt38M Offline
        michalt38M Offline
        michalt38
        wrote on last edited by michalt38
        #3

        Here are screenshots of the widget setup, is this is what you asked for? I'm also including screenshot of how the chart looks like. The whole code is in my first post.

        d34d8998-dbea-4970-ab82-c3aa714d9dc5-image.png
        05d813d4-6166-4cee-8658-bc4d9f96e3df-image.png
        9e068fea-c3e8-44a2-9ace-397d6ee37959-image.png

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

          Hi
          You seems not to insert the chartView into the layout you put on central/frame

          1 Reply Last reply
          1

          • Login

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