Anduril28 Anduril28 - 1 year ago 639
C++ Question

How do you display a QChartView in a Custom Widget?

I have a QChart that I've assigned to a QChartView. In the example I've been following the chart is displayed, in main.cpp, as:


In my project I want to utilize the designer and as such have created a custom widget, but it's not displaying the QChart. I found an example where they assigned they assigned the view to a layout and then set the layout, as such:

mainLayout = new QGridLayout;
mainLayout->addWidget(chartView, 0, 0);

But this seems to mess with the layout of all the other widgets within the window. How do I get the Custom Widget to display my chartView?

Thank you!

Answer Source

I made the class inherit from QChartView (which inherits QWidget) instead of QWidget, then did:



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download