Unsolved Correcting data by equation parameters
-
And one more question this algorithm is fast? I have a looot of data and I have to calculate it in real time:D
-
@erytcg
well, it's minimal and makes handling the expressions easier (for the programmer) but since it is sort of a text parser, not that fast but for small expressions its not wildly time consuming. -
Depending on what you need to handle, maybe using something like
https://github.com/ArashPartow/exprtk ? -
Can I use QScriptEngine?
But I have problem
#include <QtScript/qscriptengine.h> #include <QtScript/qscriptvalue.h> QString x = ui->correctDataLine->displayText(); QScriptEngine myEngine; QScriptValue x2 = myEngine.evaluate(x); qDebug() << x2.toNumber(); undefined reference to `_imp___ZN13QScriptEngineC1Ev'
-
@erytcg
do you have
QT += script
in the pro file? -
Ok thanks my bad:(
Do you think can I use this with variables names? -
@erytcg
What do you mean with "variables names" ?
To put inside QScriptEngine or what you wanna do with variables? -
Ah I see where you are aiming :)
Yes you can use it for your use case. Depending on the complexity you need.
http://www.informit.com/articles/article.aspx?p=1405559&seqNum=2
Using script with js to play calculator. -
I have this
And I have variable name: x. I put to QLineEdit 1+x * 3
And script automatically calculate new value of x.
x = 1+x*3 -
@erytcg
Only if you program in js to solve it. it can evaluate values for you but
it cant tell you what x is as far as i know. -
Why are you using JS libraries with a deprecated Qt module when @mrjj linked a good C++ library that can do what you want? there are even examples that do basically what you want to do.
If you want something that would solve generic expressions (i.e. no numeric values involved). The issue becomes a lot more complicated and, you are probably better off using a service like Wolfram Alpha's API