当前位置:网站首页>QT笔记——自定义数据类型
QT笔记——自定义数据类型
2022-07-22 08:12:00 【旧街凉风°】
1.当我们用线程发送数据时,常常会遇到下面的情况:
翻译为:
QOject::connect不能对类型为QVector<int>的参数进行队列(请确保QVector<int> 被注册通过qRegisterMetaType)
帮助文档:
所以我们尝试用qRegisterMetaType来注册我们所自定义的数据
//注册自定义数据
qRegisterMetaType<QVector<int>>("QVector<int>");
2.当我们用QVariant使用自定义数据时,常常会遇到下面的情况:
帮助文档:
让自定义的类型设置到QVariant,我们通常使用Q_DECLARE_METATYPE这个宏,需要在类外定义,需要在这个自定义类型之后才生效,否则会报错
struct Person
{
QString name;
int age;
int score;
QString className;
};
Q_DECLARE_METATYPE(Person)
边栏推荐
- [opencv introduction practice] use the front camera of the computer for face detection
- 基于攻防博弈的网络防御决策方法研究综述
- [exception] generate guid and datetime, import test data to the database
- 所有navicat版本都支持MySQL吗,为什么我打开连接不上呢?
- 学IT,你后悔了么?
- GBase8s数据库由数据库对象执行的对照
- Pointeur de fonction C et fonction de rappel
- 基于信誉管理模型的矿工类型鉴别机制设计
- GBase8s数据库SET Database Object Mode 语句
- Gbase8s database set collection statement
猜你喜欢
路由协议是什么
vcs与verdi学习记录
Dokcer running Nacos container automatic exit problem
Understanding and learning of dates
[case sharing] configure the routing penetration function of IS-IS
Computer Graphics From Scratch - Chapter 4
How to solve the gloomy life under the middle-aged crisis of it
Web3 sharing
Bigder: common business terms in 36/100 report testing
等额本金递增还款/等额本金递减按揭房贷还款计算器
随机推荐
异地多活的演变
【3D目标检测】稀疏卷积
Understanding and learning of dates
云原生强势发展,企业该如何抓住业务机遇
基于攻防博弈的网络防御决策方法研究综述
十七、C函数指针与回调函数
逆袭黑马:数据库全栈工程师(DevDBOps)培训,把最好的课程送给您!
GBase8s数据库对 SET COLLATION 的限制
prosody相关概念了解。xmpp,jabber,bosh等
Concurrent model values actor and CSP
[opencv introduction practice] use the front camera of the computer for face detection
基础SQL Server 操作问题——仅当使用了列表并且IDENTITY_INSERT为ON时,才能为表中的标识列制定显示值
【案例分享】配置IS-IS的路由渗透功能
How to declare the default value in go language structure and how to convert it into JSON data
力扣练习——26 分割数组为连续子序列
力扣练习——31 有效的井字游戏
力扣练习——27 翻转矩阵后的得分
The problem of the result set returned by MySQL stored procedure
Dokcer running Nacos container automatic exit problem
Use of bullets in object pool mode in aircraft war