Register a custom type
When signals and slots pass custom parameters in different threads, they need to be registered. Otherwise, an error will be reported:
QObject::connect: Cannot queue arguments of type'QVector'
(Make sure'QVector' is registered using qRegisterMetaType().)
Registration format:
qRegisterMetaType<MyClass>("MyClass");
E.g:
#include "widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
qRegisterMetaType<QVector<int>>("QVector<int>");
Widget w;
w.show();
return a.exec();
}
Source code: https://github.com/sunlianqi/qt/tree/master/registerMetaType .