emit std::string with qt signal
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: 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<: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