Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to display rectangle on a graph at a specific location.
preddy last edited by
I need to create a graph that displays rectangles that can be changed depending upon the user input values. And the rectangle should contain text.
I used QAreaSeries to display a rectangle but there's no function to type text over it. I need to add a rectangle to the same graph every time that function is called.
The first image is how I want to display.
The second image is how my code displays the rectangle.
QChart *qChart = new QChart();
QChartView *myChartView = new QChartView(qChart);
QValueAxis *qAxisX = new QValueAxis;
QValueAxis qAxisY = new QValueAxis;
QLineSeries *series0 = new QLineSeries();
QLineSeries *series1 = new QLineSeries();
*series0 << QPointF(1, starting_point_of_rectangle) << QPointF(1, ending_height_of_rect);
*series1 << QPointF(4, starting_point_of_rectangle) << QPointF(4, ending_height_of_rect);
QAreaSeries *series = new QAreaSeries(series0, series1);
Please let me know if I can use any other method instead of QAreaSeries which helps me get this work done a lot more easily.
Any type of help is appreciated.
I think you can reuse this example