当前位置: 首页 > news >正文

东莞网站设计制作网站网站建设框架文案

东莞网站设计制作网站,网站建设框架文案,注册公司流程和费用找哪家,做外贸网站卖什么东西好最近研究了一下QT的反射机制#xff0c; Qt的元对象系统除了提供信号/槽机制的特性之外#xff0c;它还提供了以下特性: QObject::metaObject() 返回关联的元对象 QMetaObject::className() 在运行时状态下返回类名 QObject::inherits() 判断类的继承关系 QObject::tr() Qt的元对象系统除了提供信号/槽机制的特性之外它还提供了以下特性: QObject::metaObject() 返回关联的元对象 QMetaObject::className() 在运行时状态下返回类名 QObject::inherits() 判断类的继承关系 QObject::tr()QObject::trUtf8() 提供国际化翻译字符串 QObject::setProperty()QObject::property() 通过名称来动态设置和获取属性 QMetaObject::newInstance() 创建新实例 通过QObject::metaObject()方法 所有继承于QObject的类可以 返回元对象系统为其生成的metaObject对象。QMetaObject提供的一些重要信息 QMetaClassInfo 通过宏Q_CLASSINFO的支持提供类的附加信息 QMetaEnum Qt特色的枚举对象支持key和 value之间的互转 QMetaMethod 提供类成员函数的元数据 QMetaProperty 提供类成员属性的元数据 Qt反射前期准备 1、首先得继承于Q_Object同时需要在class中加入Q_OBJECT。 2、注册类成员变量需要使用Q_PROPERTY   Q_PROPERTY( type member READ get WRITE set) 其中READWRITE是关键字   Type表示成员的类型不支持自定义类型对Qt很多基本类型都支持;   Member代表你给该成员另外起的名字可以和变量名不同getset就是自己在C函数里面定义的基本的访问函数名不需要写参数。 3、注册类成员函数   如果你希望这个函数能够被反射那么很简单只需要在类的函数声明前加入Q_INVOKABLE关键字。 参考文章 https://blog.csdn.net/playstudy/article/details/7861329 https://www.cnblogs.com/RainyBear/p/5251440.html 下面是我自己编写的实例 1.右击QT Creater中的项目名——添加新文件——选择C Class——Choose——取个Class nameTestClass——Base Class选择QObject——点击下一步——在项目文件列表中会增加一个testclass.h和testclass.cpp testclass.h中如下 #ifndef TESTCLASS_H #define TESTCLASS_H #include class TestClass : public QObject { Q_OBJECT public: explicit TestClass(QObject *parent 0); Q_INVOKABLE int sum(int na,int nb); Q_INVOKABLE int decrease(int na, int nb); signals: public slots: }; #endif // TESTCLASS_H testclass.cpp中如下 #include “testclass.h” TestClass::TestClass(QObject *parent) : QObject(parent) { } int TestClass::sum(int na,int nb) {return nanb; } int TestClass::decrease(int na, int nb) {return na-nb; }#include “testclass.h” TestClass::TestClass(QObject *parent) : QObject(parent) { } int TestClass::sum(int na,int nb) {return nanb; } int TestClass::decrease(int na, int nb) {return na-nb; }void MainWindow::on_ShowClassInfo_clicked() { TestClass classTestClass; const QMetaObject *theMetaObject classTestClass.metaObject();//定义一个QMetaObject对象指针用来获取类classTestClass的相关信息 int nMetathodCount theMetaObject-methodCount(); for(int nMetathodIndex 0;nMetathodIndex nMetathodCount;nMetathodIndex) { QMetaMethod oneMethod theMetaObject-method(nMetathodIndex); qDebug() MethodName: oneMethod.name(); qDebug() parameterNames: oneMethod.parameterNames(); qDebug()“parameterTypes” oneMethod.parameterTypes(); qDebug() typeName: oneMethod.typeName(); qDebug() “signature: oneMethod.Signal; qDebug() “methodType: oneMethod.methodType() ”\n”; } } 程序运行后点击ShowClassInfo按钮在“应用程序输出”界面会显示如下信息 MethodName: “destroyed” parameterNames: (“”) parameterTypes (“QObject*”) typeName: void signature: 1 methodType: 1 MethodName: “destroyed” parameterNames: () parameterTypes () typeName: void signature: 1 methodType: 1 MethodName: “objectNameChanged” parameterNames: (“objectName”) parameterTypes (“QString”) typeName: void signature: 1 methodType: 1 MethodName: “deleteLater” parameterNames: () parameterTypes () typeName: void signature: 1 methodType: 2 MethodName: “_q_reregisterTimers” parameterNames: (“”) parameterTypes (“void*”) typeName: void signature: 1 methodType: 2 MethodName: “sum” parameterNames: (“na”, “nb”) parameterTypes (“int”, “int”) typeName: int signature: 1 methodType: 0 MethodName: “decrease” parameterNames: (“na”, “nb”) parameterTypes (“int”, “int”) typeName: int signature: 1 methodType: 0
http://www.zqtcl.cn/news/604468/

相关文章:

  • 景区网站建设材料代运营有哪些套路坑
  • 六安电商网站建设哪家好有关做美食的网站
  • 卸载wordpress插件网店seo关键词
  • 金山网站制作赤城seo网站优化排名
  • 提供坪山网站建设深圳商城网站哪家做的好
  • 有什么网站可以帮人做模具吗热搜榜百度一下你就知道
  • 深圳网站优化技巧邹城住房城乡建设部网站
  • 小型企业网站建站桂林市中考信息网官网
  • 雏鸟app网站推广做网站用宋体有版权问题吗
  • 建立网站数据库开公司流程及费用2022最新
  • 外贸谷歌网站推广wordpress调用上传图片
  • 360提示危险网站原因威海 网站开发
  • 赣州本地网站网站怎么写
  • 物业公司网站设计湛江做网站软件
  • 做招聘求职网站wordpress启用插件出错
  • 珠海网站运营网站个人备案流程
  • 网站开发用什么图片格式最好网络营销名词解释是什么
  • 做柜子网站老电脑做网站服务器
  • 域名购买网站网店装修是什么
  • wordpress 网站备份为什么企业要建设自己的企业文化
  • 想做一个部门的网站怎么做潍坊网站建设价
  • 网站建设公司的公司哪家好什么行业必须做网站
  • 电子商务网站前台设计wordpress 上传文件大小
  • 深圳市住房和城乡建设局网站非常好的资讯网站设计
  • 长春作网站建设的公司国家建设环保局网站
  • 网站开发的有哪些好的软件wordpress菜单栏的函数调用
  • 家庭清洁东莞网站建设技术支持建筑模板厂投资多少钱
  • 郑州企业建站详情网站开发和网页开发有什么区别
  • 山西古建筑网站个人网站可以做自媒体吗
  • 腾讯云服务器可以做网站wordpress中文正式版