So obviously in the View, I don't want it to know about how to graph is made, ideally I would just like it to display it.
I have a slot function which does this in my datatesttab.cpp, it is activated upon pressing a button in my GUI.
void DataTestTab::setGraphs(QCustomPlot* plot) { ui->graphDataTest->addPlottable(plot); }
Obviously this doesn't work, but you get the idea how I'd just like to pass it the "canvas" if that makes sense.
I then have another class in my model, which when this button is pressed, returns a value to the above slot:
QCustomPlot* DataTest::runTest() { QCustomPlot *customPlot = new QCustomPlot(); QCPPlotTitle *title = new QCPPlotTitle(customPlot); title->setText("Plot Title Example"); title->setFont(QFont("sans", 12, QFont::Bold)); QCPAxisRect *topAxisRect = new QCPAxisRect(customPlot); customPlot->plotLayout()->clear(); customPlot->plotLayout()->insertRow(0); customPlot->plotLayout()->addElement(0, 0, title); customPlot->plotLayout()->addElement(1, 0, topAxisRect); return customPlot; }
I know the above code doesn't work, which is why I'm asking how I should be going about this in a Model/View. I would ideally like it to be flexible, as in I can choose what type of graph I ass and how many I'm going to add to a "canvas".
Thanks!