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.