gpt4 book ai didi

c++ - 发出带有 qt 信号的 std::string

转载 作者:IT老高 更新时间:2023-10-28 23:15:17 34 4
gpt4 key购买 nike

我正在尝试使用 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/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com