QSA-interest Archive, February 2006
Representing QMap<QString, QString> in QScript
Message 1 in thread
Hey,
I have members of a QScript accessible object
that take a QMap<QString, QString> as a parameter.
I created a StringMap class that represents this
container and registered it with a factory. Is there
a better/cleaner way?
Ideally I would like:
In C++,
void ClassName::method( QMap<QString, QString> );
and in QScript,
var map = [];
map[ "key" ] = "value";
ClassObject.method( map );
Right now I have to have two methods:
1. void ClassName::method( QMap<QString, QString> );
2. void ClassName::method( StringMap * );
and instantiate a StringMap object in QScript:
var map = new StringMap;
map.add( "key", "value" );
ClassObject.method( map );
which internally calls 1. ClassName::method( StringMap->QMap<QString,
QString> );