[Qt-interest] Advise on best way to implement javascript

Dan Alcantra dalcantra at yahoo.com
Fri May 20 21:35:07 CEST 2011


Hi Qt Experts.

I have a spreadsheet application where the rows get populated from a socket.  I 
want to give the user the ability to filter our data with simple algebraic 
expressions.  I decided to try QScript.  I have it in a rough state where it 
works and now  I want to make sure I am doing it in the most efficient manner, 
as the data feed may be very fast.

The user writes in the script into a QTextEdit  class, they may write something 
like this:

if ((A < 100) && (B > 20))
  return true;
else
  return false;

My Qt code for running the script looks like this:

   QString str = textEdit->toPlainText();
   QScriptEngine engine;

 for(int i=0;i<numRows,i++) {
   // put arguments for A,B,... into str
   QScriptProgram program(str);
   QScriptValue result = engine.evaluate(program);
}


As I need to do this for hundreds of rows is there a more efficient way to 
execute  the script so that it gets set up once and then evaluated for  every 
row.   Is there a way to use a jit compiler to speed things up ?

Any advise on how to optimize this kind of Java scripting is appreciated very 
much
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110520/2186d589/attachment.html 


More information about the Qt-interest-old mailing list