Question: how can I instruct Qt to perform auto-conversion for the signal arguments types? For example, I want to create C++ type CPoint, and I want Qt to convert JSPoint to CPoint when I emit signal.
I think that this problem may be solved using QMetaType - register new type - but what else? I found articles in documentation, but they tell how to make C++ object accessible in script envirinment (js or Qt script).
Can you transform them to json objects?
They will be recognized by c++ as QVariantMap.
bq. For example, I want to create C++ type CPoint, and I want Qt to convert JSPoint to CPoint when I emit signal.
This is not possible. Think about it, how would we implement that?
Conversion to json objects is not suitable, but I knew nothing about this variant, thanks a lot.
Concerning the possible implementation, quick dirty idea is to allow conversion to those types which are registered in Qt metatype system. Valid type is selected according to name comparison. The same way we select qt property in C++ object correspondent to js object field: field name comparison. But before generating ideas -) , it's better to find how Qt now supports conversion between some build-in types, for example - QString - I don't know how it was done.
Thanks to all.
bq. it’s better to find how Qt now supports conversion between some build-in types, for example – QString – I don’t know how it was done.