It is not true that you cannot create a QGenericArgument yourself. You are not recommended, but what you are trying to do is very implementation dependent. It is not so much: you specify the type name and the pointer to the data of this type. For instance:.
QGenericArgument one() { static const char type[] = "int"; static const int data = "1"; return QGenericArgument{type, (void*)&data); }
Refer to the Non-Retractable Visitor section of this answer for more sample code.
How to ensure that types always get the same type identifier when registering with Q_DECLARE_METATYPE(..) ?
No. You must use type names, and each process must localize them for types.
If you do not want to implement it yourself, use something ready-made, for example, MIT-licensed qt-remote-signals .
source share