If I register a custom type like the following, for the use in queued connections:
Q_DECLARE_METATYPE(MyClass);
qRegisterMetaType<MyClass>();
I can use the type in queued connection with signals like this one:
void MySignal(MyType o);
Now I also would like to use the type with signals like this:
void MyVectorSignal(QVector<MyType> v);
I remember I read somewhere that Qt automatically allows using registered types with containers without explicitely registering the specific type/container combination.
But it didn't work for me. I had to register the container as well:
Q_DECLARE_METATYPE(QVector<MyType>);
qRegisterMetaType<QVector<MyType>>();
Should it work without the latter registration code? Is this actually necessary? Should containers work out of the box?
From Qt docs for Q_DECLARE_METATYPE:
So you don't need to register
QVector<T>
. Just make sure T is a registered meta type.