c++ - How to use template types as slot and signal parameters in multiple threads? -



c++ - How to use template types as slot and signal parameters in multiple threads? -

can utilize template type in way slot or signal argument? example, i'm trying define following:

void examplesignal(std::map<non_template_type_1,non_template_type_2> arg); void exampleslot(std::map<non_template_type_1,non_template_type_2> arg);

this results in next during runtime:

qobject::connect: cannot queue arguments of type 'std::map<non_template_type_1,non_template_type_2>' (make sure 'std::map<non_template_type_1,non_template_type_2>' registered using qregistermetatype().)

trying register std::map<non_template_type_1,non_template_type_2> q_declare_metatype() results in compilation failure , apparently not supported.

as workaround, i'm using qvariantmap instead of std::map. know right way solve problem; 1 not possible modify template classes.

edit: forgot mention signal , slot emitted , received in different threads. apparently runtime error doesn't occur in single-thread scenarios.

as explained in this thread can seek using typedef, including qmetatype header , using both q_declare_metatype macro , qregistermetatype function (as implied this thread on similar issue).

c++ qt templates signals-slots

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -