Reputation: 14042
I have a QVariantMap
, which I would like to pass to Javascript via a signal.
c++:
signals:
void mysignal( QVariantMap map );
QVariantMap map;
map.insert( "id", 54 );
emit mysignal( map );
js:
mybinding.mysignal.connect( this, function( map ) {
alert( "Map: " + map );
} );
Now the alert just displays Map:
.
Could someone tell me what I am doing wrong?
Upvotes: 1
Views: 401
Reputation: 21
mybinding.mysignal.connect( this, function( map ) {
alert( "Map: " + map );
} );
You map is a object (QVariantMap). so if you wan to access the values you should use
mybinding.mysignal.connect( this, function( map ) {
alert( "Map_ID: " + map.id );
} );
This give you an alert message indicating 54
Upvotes: 1
Reputation: 14042
Found that passing via QVariant
works:
c++:
signals:
void mysignal( QVariant map );
QVariantMap map;
map.insert( "id", 54 );
emit mysignal( QVariant::fromValue(map) );
Why the binding does work only this way? I have no idea.
Upvotes: 0