QTreeWidgetItem的setData(int column,int role,QVariant& data)等,

上传者: aoxuestudy | 上传时间: 2023-04-14 09:48:37 | 文件大小: 1.18MB | 文件类型: RAR
Qt中QVariant是多种类型的联合,QVariant类中有个SetValue(T& value)方法,将自定义 T 类型的数据保存到QVariant对象中,可以理解为是自定义类型被封装成了QVariant的形式,这样,我们自定义的T类型的对象就能够通过所有参数和返回值为QVarian类型传递。比如QTableWidgetItem的setData(int column,QVariant& data)和QTreeWidgetItem的setData(int column,int role,QVariant& data)等,通过setData函数我们可以为每个单元格保存自己想绑定的数据及为每个树节点保存想绑定的自定义类型的数据。   但是,QVariant中的setValue方法的使用有个前提,就是我们自定义的类型要能被Qt所识别。那该怎样识别呢?   这就要用到宏定义Q_DECLARE_METATYPE了,通过这个宏定义可以将自定义的类型注册到Qt的元类型中,从而被Qt识别,通常在自定义类型定义之后使用。

文件下载

资源详情

[{"title":"( 29 个子文件 1.18MB ) QTreeWidgetItem的setData(int column,int role,QVariant& data)等,","children":[{"title":"QTreeWidgetItemTest","children":[{"title":"User.cpp <span style='color:#111;'> 210B </span>","children":null,"spread":false},{"title":"Makefile.Debug <span style='color:#111;'> 50.17KB </span>","children":null,"spread":false},{"title":"Resource.qrc <span style='color:#111;'> 108B </span>","children":null,"spread":false},{"title":"QTreeWidgetItemTest.pro <span style='color:#111;'> 1.08KB </span>","children":null,"spread":false},{"title":"ui_MainWindow.h <span style='color:#111;'> 1.85KB </span>","children":null,"spread":false},{"title":"Images","children":[{"title":"ruiwen.png <span style='color:#111;'> 7.06KB </span>","children":null,"spread":false}],"spread":true},{"title":"User.h <span style='color:#111;'> 327B </span>","children":null,"spread":false},{"title":"MainWindow.ui <span style='color:#111;'> 558B </span>","children":null,"spread":false},{"title":".qmake.stash <span style='color:#111;'> 1.42KB </span>","children":null,"spread":false},{"title":"Makefile.Release <span style='color:#111;'> 50.11KB </span>","children":null,"spread":false},{"title":"QTreeWidgetItemTest.pro.user <span style='color:#111;'> 23.56KB </span>","children":null,"spread":false},{"title":"MainWindow.h <span style='color:#111;'> 771B </span>","children":null,"spread":false},{"title":"main.cpp <span style='color:#111;'> 183B </span>","children":null,"spread":false},{"title":"debug","children":[{"title":"moc_User.obj <span style='color:#111;'> 1.55KB </span>","children":null,"spread":false},{"title":"User.obj <span style='color:#111;'> 63.48KB </span>","children":null,"spread":false},{"title":"QTreeWidgetItemTest.ilk <span style='color:#111;'> 1.74MB </span>","children":null,"spread":false},{"title":"moc_User.cpp <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"qrc_Resource.cpp <span style='color:#111;'> 39.29KB </span>","children":null,"spread":false},{"title":"moc_MainWindow.cpp <span style='color:#111;'> 4.76KB </span>","children":null,"spread":false},{"title":"main.obj <span style='color:#111;'> 101.37KB </span>","children":null,"spread":false},{"title":"moc_predefs.h <span style='color:#111;'> 276B </span>","children":null,"spread":false},{"title":"QTreeWidgetItemTest.exe <span style='color:#111;'> 116.50KB </span>","children":null,"spread":false},{"title":"MainWindow.obj <span style='color:#111;'> 232.66KB </span>","children":null,"spread":false},{"title":"QTreeWidgetItemTest.pdb <span style='color:#111;'> 2.51MB </span>","children":null,"spread":false},{"title":"qrc_Resource.obj <span style='color:#111;'> 14.71KB </span>","children":null,"spread":false},{"title":"QTreeWidgetItemTest.vc.pdb <span style='color:#111;'> 1.80MB </span>","children":null,"spread":false},{"title":"moc_MainWindow.obj <span style='color:#111;'> 105.35KB </span>","children":null,"spread":false}],"spread":false},{"title":"MainWindow.cpp <span style='color:#111;'> 2.20KB </span>","children":null,"spread":false},{"title":"Makefile <span style='color:#111;'> 30.00KB </span>","children":null,"spread":false},{"title":"release","children":null,"spread":false}],"spread":false}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明