Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emit std::string with qt signal

Tags:

c++

qt

qt4

I am trying to emit standard string with qt signal. The signal will be delivered as queued. I registered the type with qRegisterMetaType , like it says in the qt documentation, but no luck. I am registering it like this qRegisterMetaType<std::string>("std::string")

like image 550
user152508 Avatar asked Oct 08 '11 18:10

user152508


1 Answers

You should also do:

Q_DECLARE_METATYPE (std::string)

Quoting Qt Doc

Adding a Q_DECLARE_METATYPE() makes the type known to all template based functions, including QVariant. Note that if you intend to use the type in queued signal and slot connections or in QObject's property system, you also have to call qRegisterMetaType() since the names are resolved at runtime.

like image 149
RushPL Avatar answered Oct 13 '22 19:10

RushPL