我正在尝试使用 qt 信号发出标准字符串。信号将按队列传递。我用 qRegisterMetaType 注册了类型,就像它在 qt 文档中所说的那样,但没有运气。我是这样注册的
qRegisterMetaType<std::string>("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++ - 发出带有 qt 信号的 std::string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7698986/