[Qt-interest] Best way to add filter to data
Konrad Rosenbaum
konrad at silmor.de
Sun Feb 27 09:38:49 CET 2011
On Sunday 27 February 2011, Dan Alcantra wrote:
> I have many table widgets each with their live data feed that adds rows,
> and each with its own schema such as "name, time, value1,value2,..."
> Under each table I have a text window that I want to allow the user to
> enter simple algebraic expressions to filter out data they do not want.
> For instance a user might type in "if (name == sensorA)" or something
> like "if (value1< 10 && value2 > 100".
>
> Rather then create my own interpretor for the algebra I wanted to use Qt
> Script. I know Qt well enough but how to interface with Qt Script is
> the question.
You need to instantiate a QScriptEngine instance. You either wrap all your
values as QScriptValues or (easier) you implement a QObject that provides
them as slots and then add the object with globalObject().setProperty(...).
Then you call one of the evaluation methods to get values.
> Or should I use something else like Perl,
I recommend not to use Perl - it is devilishly hard to integrate. Other
Languages like Python or Tcl are easier, but each one will need extensive
integration work.
> or maybe there
> is a C++ library that allows for simple algebra evaluations. Has anyone
> done something like this ?
I did.
A basic Tcl integration: https://silmor.de/svn/qtkde/qtcl (I never went very
far with this free (GPL) implementation, but I'm using Tcl in a commercial
project with great success).
A simple algebraic library: https://silmor.de/svn/elam - it does not have
advanced scripting capabilities, just evaluating simple expressions and a
few functions. (It's under LGPL.)
> Any suggestions as to how to start is very much appreciated.
Konrad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110227/3e12cd28/attachment.bin
More information about the Qt-interest-old
mailing list