QCustomPlot Discussion and Comments

UI QCustomPlot HELP!Return to overview

Is there any way that I can enter my own function into a "lineEdit" and plot that function int to QCustomPlot?

My function is: sin(x);
and i can plot it by doing
y = sin(x);
but I want to enter my own function of any kind.
y = ui->lineEdit->text();

Like somthing as that but in a way that'll work. Greetings!

For that you'll have to parse the mathematical expression in the string. While simple mathematics such as brackets, addition, multiplication, exponentiation, and trigonometric functions you could parse and process manually, beyond a certain point it makes sense to use a library for that (especially if you plan to use non-elementary functions which don't have a direct representation in the C++ standard library, like Error, Airy, Bessel, Integrals, Series, etc.)
Ways to parse math expressions are abundant if you google for it. Math parser libraries can also easily be found (e.g. ExprTk, bcParserCPP, muParser, fparser, cparse, Lepton, or the more powerful package GiNaC,...).

In any case, QCustomPlot is not a math expression parser library, so you'll have to do that part and then pass the numerical data points to e.g. a QCPGraph.