QSharedPointer<UserDataType> as signal/slot parameters
In general a user data type should be registered with the meta system in order to be used as parameters in signal/slot queued communication. How about a QSharedPointer to a user data type. Is that safe? Does it matter if the user data type is registered?
If QSharedPointer can’t be used I suppose a raw pointer would be ok (provided I can manage the lifetime of the object correctly). Right?
Thanks
4 replies
In that case, I think you need to register them. Make a typedef for QSharedPointer<UserDataType>, and use both Q_DECLARE_METATYPE as well as qRegisterMetaType() to register it for use.
Correct. The Q_DECLARE_METATYPE macro is necessary in both cases. qRegisterMetaType is required for the queued connection.
You must log in to post a reply. Not a member yet? Register here!


