QCustomPlot Discussion and Comments

Basic plotting helpReturn to overview

Can anyone describe as simply as possible how to run the example code shown on those beautiful plots on the QCustomplot home page? I've run the quadratic_demo, and the code for that is included in a much larger .cpp file that I'm not sure I totally follow. Is that also true of all the example code on the home page? I'm a total newbie to Qt and QCustomplot.
Thanks!

The main example code files (both in mainwindow.cpp and mainwindow.h) contain a big fat explanation comment at the top. Did you read that?

Thanks for your prompt and explicit help! I looked at the explanation comments in both mainwindow.cpp and mainwindow.h, but did not understand the explanation in either. In other words, if I wanted to run one of the plots, for example something other than quadratic_demo, exactly what steps do I need to take to run a specific plot? Or alter the code of one specific plot, and then use the mainwindow widget to see a particular plot. I repeat, I am an ultra-newbie in Qt and QcustomPlot, so I would appreciate a more explicit step-by-step description of running a specific plot than what is commented on in the two modules you refer to. I want to use qmake and make, or QtCreator, it doesn't matter I have both installed on Linux Mint 18.1.
Thanks for your consideration in this matter,
Robert M. Koretsky

Start up QtCreator, and load the plot examples project file (QCustomPlot/examples/plots/plot-examples.pro)

On the left, you go to mainwindow.cpp

There, navigate to the constructor of the MainWindow class. Should be the first method, somewhere around line 50.

The call of setupDemo(0) causes the quadratic demo code to be executed. From the longer comment below that call, you can deduce the number of each demo. For example, If you want to load the Logarithmic Axis Demo, call setupDemo(9) instead.

Then press the "play" button on the bottom left, to compile and execute the application.

The code of each demo (each corresponds to a screenshot on the website) is in its own function. Those functions are in that same mainwindow.cpp one after the other: void MainWindow::setupQuadraticDemo, void MainWindow::setupSimpleDemo, and so on, with their respective implementations.

Please let me know which part of the comment in the mainwindow.cpp would have needed improvement, to make it understandable for you without my help. Thanks!

DerManu:
Beautiful description, very complete, helpful, and considerate!
Thanks! I will go through all you have written above, and get together a suggested write up for inclusion as documentation in mainwindow.cpp.
I vote for you as President of the United States, to replace the clown in there now. You can have Arnold as your VP.
Bob Koretsky

DerManu:
So here it is , Mr. President:
In QtCreator, after you open the project (QCustomPlot/examples/plots/plot-examples.pro), you then need to also use the File>Open menu to open the file mainwindow.cpp! Once that's seen in the main pane, scroll down to Line 57 (to be exact), and change the argument to setupdemo from the default 0 to any of the integers you want to see a demo plot of. Then hit the play button.
I would change the comment in mainwindow.cpp and mainwindow.h to read as a shortened version of what you wrote to me in your last Reply, and my modifications to it as seen in this reply. Leave out the reference to the constructor of the MainWindow class, that really threw me as a novice to C++, and Qt in general.
Now its on to the bigger fish to fry for me: a)extracting just the code for only one demo plot into its own project! And b) getting rid of declaring variables like x and y in the quadratic_demo by using QVector. I want to just use a C++ array declaration, if that's possible.
Again, much thanks for your excellent help!

Hi ;

I have a video for ploting basic QCustomplot Graph. You can watch :)

https://www.youtube.com/watch?v=xWGEvlDWokQ

Just as a hint: For C++ novices I'd strongly advise against using raw C arrays, as it is too easy to shoot yourself in the foot with them, apart from being laughably impractical, seen from the context of the year 2017. There is no advantage. The speed advantage over QVector or std::vector is theoretical, and absolutely negligible in anything a novice will write.

Elif & DerManu:
Thanks for that video, it's exactly what I was looking for! I have to deconstruct it and slow down the steps a little because I'm a newbie, but it looks excellent.
As far as QVector goes, thanks for the info on that! I'm not really sure what the QVector adds, placing x and y in a class structure? Python, C++ are multi-paradigm languages.
The big reason for using a "raw C array" is that my prime directive is to strongly partition number generation from Qt. I raised this issue on the Qt Forums, and I don't think anyone there understood the point of doing that. I think their basic objection was that the Qt code should be considered in a universe all it's own, and if you are doing even just a little bit more than trivial number generation, hooking number generation to Qt code is not germane to coding in Qt.
Think of it this way- I have some algorithms implemented in C that generate some numbers. Without changing any of that C code, if you cleanly partition number generation from Qt graphics, your system is neatly modularized ( a basic tenet of structured programming.) I mean this is clearly shown in the QCustomplot examples: there's a comment above each block of code that generates the numbers.
Any commentary you have on this is greatly appreciated.

I have researched the QVector a little more, and now agree with DerManu: the QVector is the more modern and useful form. Many numerical recipes, in their modern implementations, should be coded using C++.