Hi,
I need to create a Qt script dynamically from user input formular using QRegExp. I got completely lose. Please help.
I have a list of QVector<float> a, aa, b, etc... which I can transfer to QScriptEngine.
I have a QLineEdit to allow user to enter their own formular to compute a new one, for instance, use can enter the following string (case insensitive):
math.max(a)/math.min(aa)*b+aa/b-Math.pow(aa)/a/MATH.pow(a,2.14)
I need to convert this string into QtScript dynamically, so it should become:
var max_a = max( a ); // max is a global function somewher in my script library
var min_aa = min( aa ); // min is a global function somewher in my script library
var result = new Array;
for ( var idx = 0; idx < a.length; idx++ ) {
result[ idx ] = max_a / min_aa * b[ idx ] + aa[ idx ] / b[ idx ] - Math.pow( aa[ idx ] ) / a[ idx ] / Math.pow( a[ idx ], 2.14 );
}
var max_a = max( a ); // max is a global function somewher in my script library
var min_aa = min( aa ); // min is a global function somewher in my script library
var result = new Array;
for ( var idx = 0; idx < a.length; idx++ ) {
result[ idx ] = max_a / min_aa * b[ idx ] + aa[ idx ] / b[ idx ] - Math.pow( aa[ idx ] ) / a[ idx ] / Math.pow( a[ idx ], 2.14 );
}
To copy to clipboard, switch view to plain text mode
I believe I need to use QRegExp, but am unable to get it done.
Many thanks!!
Bookmarks