Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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

    Hi,

    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.

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


  • Lifetime Qt Champion

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


Log in to reply