Qobject::connect:cannot queue arguments of type ' qmap<qstring,qstring> ', (make sure ' qmap<qstring,qstring> ' is registered using Qregistermetatype ().).
The above error occurs only when cross-thread signaling is passed. Because Qmap is a basic type of QT-aware, it does not require a re-registration in the meta-object system, and there is no problem running in the same thread.
Source:
CPP Code
- // thread class thread.h
- class thread:PUBLIC&NBSP;QTHREAD&NBSP;&NBSP;
- {
- q_object
-
- PUBLIC:&NBSP;&NBSP;
- thread () {}
- ~thread () {}
-
- PROTECTED:&NBSP;&NBSP;
- virtual void run ();
-
- signals:
- void sendmsg (const qmap<qstring,qstring> &msgs) ;
- }
CPP Code
- Signal Reception class Test.h
- Test (Thread *th): m_th (TH)
- {
- //Different threads are connected in queue mode
- Connect (m_th,signal (sendmsg (const qmap<qstring,qstring> &)),This,slot (handle (const qmap< Qstring,qstring> &), qt::queuedconnection);
- }
Solution: Register to Metype with the Qregistermetatype () method
CPP Code
- Thread.h
- typedef qmap<qstring,qstring> STRINGMAP; the//typedef operator is an alias for Qmap
- void sendmsg (const STRINGMAP &);
CPP Code
- Test.h
- Test (Thread *th): m_th (TH)
- {
- //Register Qmap to meta-object system
- Qregistermetatype<stringmap> ("Stringmap");
- Connect (m_th,signal (sendmsg (const STRINGMAP &)),This,slot (handle (const STRINGMAP &)), Qt:: Queuedconnection);
- }
http://tcspecial.iteye.com/blog/1897006
Object::connect:cannot queue arguments of type ' qmap<qstring,qstring> ' (to use Qregistermetatype<stringmap > Registration)