Correcting data by equation parameters
-
@erytcg
yeah should be as you can just treat the variable as a number and substitute when you calculate the result.
it also support operator precedence but stuff like
x=(1.3x+1)^2;
will require somewhat a more data complex model to handle flawless i think. -
And one more question this algorithm is fast? I have a looot of data and I have to calculate it in real time:D
-
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'
-
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'
-
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 -
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