I use this helper macro for this (register a metatype in runtime):

template <class T>
inline void qRegisterMyMetaType(const char *name)
{
    if (QMetaType::type(name) == QMetaType::UnknownType)
        qRegisterMetaType<T>(name);
}

#define Q_REGISTER_MY_METATYPE(type) qRegisterMyMetaType<type>(#type);


Usage example:

Q_REGISTER_MY_METATYPE(QCryptographicHash::Algorithm);

:)


On 9/26/2020 5:48 PM, Alexander Dyagilev wrote:

I'm not sure what you mean exactly, but I've seen many such situations (when connection did not work because metatype was not registered) and never saw any warnings anywhere.

On 9/26/2020 12:02 PM, Giuseppe D'Angelo via Interest wrote:
Il 26/09/20 07:55, Alexander Dyagilev ha scritto:
Yeah, it's possible that some metatype (used in signal) is registered in
Qt 5.12 and is NOT registered in Qt 5.15, thus connection does not work
between objects in different threads.

It's required to register it manually then.

Do you know of a case where this wouldn't spit the usual "arguments are not registered" warning? (If so, that's a bug)

Thanks,

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to