c – 用qt信号发出std :: string

前端之家收集整理的这篇文章主要介绍了c – 用qt信号发出std :: string前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图用qt信号发出标准字符串.信号将被排队等待.我用qRegisterMetaType注册了类型,就像在qt文档中说的那样,但没有运气.我正在注册
qRegisterMetaType<的std :: string&GT( “的std :: string”)

解决方法

你也应该做:
Q_DECLARE_MetaTYPE (std::string)

报价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.

猜你在找的C&C++相关文章