当前位置:网站首页>[qt] meta object system
[qt] meta object system
2022-07-27 00:35:00 【Sy++】
The meta object system consists of three parts :
QObject Base class : The base class of all classes that use the meta object system
Q_OBJECT macro : Enable classes to use the properties of meta objects , Such as dynamic properties 、 Signals and slots, etc
MOC: Cloud object compiler , For each QObject Subclasses of provide the necessary code to implement the characteristics of the meta object system
besides , Meta objects also provide the following functions :
- QObject::metaObject() function
return QMetaObject—— Class associated meta objects , It contains some interface functions for accessing meta objects , for example QMetaObject::className() function , You can return the name string of the class .
- QMetaObject::newInstance() function
Create a new instance of the class
- QObject::inherits(const char* className) function
Judge whether an object instance is named className Class or QObject An instance of a subclass of , for example :
QTimer *timer=new QTimer;
timer->inherits("QTimer"); //true
timer->inherits("QObject"); //true
timer->inherits("QAbstractButton"); //false- QObject::tr() and QObject::trUtf8() function
Translate string , For multilingual interface design
- QObject::setProperty(const QString &name,value) and QObject::property(const QString &name) function
Used to pass the attribute name , Set and get attribute values dynamically , for example :
QPerson p;
p->setProperty("name"," Xiao Ming ");
p->property("name").toString();// The return is " Xiao Ming "- qobject_cast<T *>(className) Coercive transformation
Can be className class , Cast to its base class , for example :
QObject *obj=new QMyWidget;
QWidget *widget=qobject_cast<QMyWidget*>(obj);Usually with sender() Function coordination , To cast the obtained signaled class into its base class , Easy to operate .
边栏推荐
- In JS, the common writing methods and calling methods of functions - conventional writing, anonymous function writing, taking the method as an object, and adding methods to the object in the construct
- 【 Educational Codeforces Round 132 (Rated for Div. 2) A·B·C】
- Matlab simulation of image reconstruction using filtered back projection method
- 【3. 基础搜索与图论初识】
- Openharmony quick start
- "Could not load host key" error when xshell connects to the server
- 【Codeforces Round #808 (Div 2.) A·B·C】
- Deploy yolov5 error reporting in pycharm
- 6_梯度下降法(Gradient Descent)
- 2022-07-17:1, 2, 3... N-1, N, n+1, n+2... In this sequence, only one number has repetition (n). This sequence is unordered. Find the repeated number n. This sequence is ordered. Find the repeated numb
猜你喜欢
![[qt] container class, iterator, foreach keyword](/img/88/d9d5be096009b4e5baa0966e6f292c.jpg)
[qt] container class, iterator, foreach keyword

MySql

TypeScript(tsconfig.json)

Uni app learning (II)

6_梯度下降法(Gradient Descent)

Lt9611ux Mipi to HDMI 2.0 dual port with audio

CSDN article syntax rules
![[3. Basic search and first knowledge of graph theory]](/img/a2/dced231f746cc049d310e364a81856.png)
[3. Basic search and first knowledge of graph theory]

Web middleware log analysis script 2.0 (shell script)

Shufflenet series (2): explanation of shufflenet V2 theory
随机推荐
Linux系统中安装Redis-7.0.4
Signal and system learning zero input response
Reduced dimension mean dot product matrix multiplicative norm probability normal distribution square loss
Downloading and processing of sentinel-2
Deep learning of parameter adjustment skills
Draw impact function
Mysql常用函数(汇总)
Eight queens n Queens
[Qt]解决中文乱码问题
2020-12-22 maximum common factor
In JS, the common writing methods and calling methods of functions - conventional writing, anonymous function writing, taking the method as an object, and adding methods to the object in the construct
Arcgis和Cass实现断面展高程点
【4.2 约数】
[3. VIM operation]
13_ Ensemble learning and random forests
用New,delete和用malloc,free申请,释放堆区空间
5_线性回归(Linear Regression)
Complete review of parsing web pages
Configure deeplobcut 1 with your head covered
Machine learning model -- lightgbm