"Cannot queue arguments of type" even after call qRegisterMetaType()
-
I need to use signal/slot to transmit data from a QThread to the main thread, the data is of type QMap<int, QVector<MyType>>.
I use a typedef to describe the data structure:typedef QMap<int, QVector<MyType>> CompType;
And I try to register it almost everywhere, including in the constructor of the QThread
MyThread::MyThread() { qRegisterMetaType<CompType>("CompType"); }
and in the constructor of the class in which start the thread
ThreadStarter::ThreadStarter() { qRegisterMetaType<CompType>("CompType"); }
even in the main() function
int main(int argc, char *argv[]) { qRegisterMetaType<CompType>("CompType"); QCoreApplication::addLibraryPath("./"); QApplication a(argc, argv); PointAnalysis w; w.show(); return a.exec(); }
But when I emit a signal at the end of thread run()
CompType data; /* Fill in the data */ emit threadDone(data);
There is a such line in the Debug log:
QObject::connect: Cannot queue arguments of type 'Part_Candidates'
(Make sure 'Part_Candidates' is registered using qRegisterMetaType().)The signal and the slot are connect just below the thread is created, and I'm sure the parameters of them are definately the same as CompType.
Anyone can tell me what to do?
-
@chuanlau said:
Hi
MyType
Is that type also registered?
Also Part_Candidates is
QMap<int, QVector<MyType>> Part_Candidates ? -
@mrjj Sorry, Part_Candidates is just CompType. It is the name in my original code. I change its name to CompType in the post. I didn't register MyType. I will try and let you know the result.
-
I need to use signal/slot to transmit data from a QThread to the main thread, the data is of type QMap<int, QVector<MyType>>.
I use a typedef to describe the data structure:typedef QMap<int, QVector<MyType>> CompType;
And I try to register it almost everywhere, including in the constructor of the QThread
MyThread::MyThread() { qRegisterMetaType<CompType>("CompType"); }
and in the constructor of the class in which start the thread
ThreadStarter::ThreadStarter() { qRegisterMetaType<CompType>("CompType"); }
even in the main() function
int main(int argc, char *argv[]) { qRegisterMetaType<CompType>("CompType"); QCoreApplication::addLibraryPath("./"); QApplication a(argc, argv); PointAnalysis w; w.show(); return a.exec(); }
But when I emit a signal at the end of thread run()
CompType data; /* Fill in the data */ emit threadDone(data);
There is a such line in the Debug log:
QObject::connect: Cannot queue arguments of type 'Part_Candidates'
(Make sure 'Part_Candidates' is registered using qRegisterMetaType().)The signal and the slot are connect just below the thread is created, and I'm sure the parameters of them are definately the same as CompType.
Anyone can tell me what to do?
-
@chuanlau
np.
I think i recall something about a post with QList and same issue and answer was to register the
type in the list, not the list itself. -
In my case i had to call:
Q_DECLARE_METATYPE(Type)
see http://doc.qt.io/qt-5/qmetatype.html#Q_DECLARE_METATYPE@beecksche Yes! You are right! This time it works. Thank you!