Trolltech Home | QSA-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

QSA-interest Archive, November 2005
How to realize selection array in QSA?


Message 1 in thread

Hi!

We have a problem with QSA 1.1.3. Perhaps someone could help us.

This is what we like to do:
We need to have a "Selection"-Object in our scripting environment. This object should hold the current selection of our 
application, e.g. a page or a diagram or ten diagrams. The user should preferably be able to type only Selection[0] or 
Selection(0) to get the first selected object for example. So we don't like to add a real C++ object "Selection" to the 
scripting engine because then the user has to type Selection.getObj(0) or something similar.
There should also be a function "Selection.length()" (or similar) that returns the number of currently selected objects.
The easiest way would be to call QSInterpreter::addTransientVariable("Selection", selObjects), where selObjects is an 
array of the selected objects, but I think that addTransientVariable is only possible for single QObjects or arrays of 
ints, strings ..., but not for arrays of QObjects.
Our next thought was to execute a small piece of scriptcode like "const var Selection = [selObject1, selObject2]" and to 
call QSInterpreter::evaluate() with this code. But we got an unpredictable behaviour when executing scripts. For example 
when we evaluate scriptcode like this:

    var projs = new Array("proj1", "proj2", "proj3");
    Application.Spck.openProject(projs[0]);

where openProject() will change the selection (so it calls QSInterpreter::evaluate()), then after opening the project 
the projs array contains only one element. Is this a bug in QSA or isn't it possible to call QSInterpreter::evaluate() 
while evaluating script code?
So does someone have any ideas how to realize our selection object in QSA?

Bye
Marcus

____________
Virus checked: AVK 16.1469 from 07.11.2005