Important: Please read the Qt Code of Conduct -

Resize QChartView automatically

  • 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?

  • Lifetime Qt Champion


    Please show the complete widget setup with the QFrame.

  • 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.


  • Lifetime Qt Champion

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

Log in to reply