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")
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.