关键词不能为空

当前您在: 主页 > 英语 >

Qt类的大致简介

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-02-28 01:06
tags:

-

2021年2月28日发(作者:leye)


1.


全继承于


QObject


拥有单根继承的优势,如


3


2.F1


可直接获取类的信息,库类不求人,


^-^


别忘了点


More


ts() metaObject() -->JAVA


里的


getclass instance < /p>


对于


C++


里的


类上转型能方便进行下转型判断了



QTimer *timer = new QTimer; // QTimer inherits QObject


timer->inherits(


timer->inherits(


timer->inherits(


QObject *obj = new QPushButton;


obj->metaObject()->className(); // returns


QPushButton::ame(); // returns


//


定义名字是由


objectName()


yed deleteLater


在析构函数之前调用,


deleteLater


可调用多次




的帮助文档常常有


i.e.


和实例代码



6.


事件处理机制相当方便



signal and slot


(信号发出与 接收机制):


QObject::connect


需要


Q_Object



事件机制:


event()



7.*


“Qt's Property System” Qt



Property(

< br>属性


)


机制


//


广泛用于


QStaticMachine



个人认为这是一种可以极大的简化面对对象的使用与扩展的机制(不用

< br>在混乱里继续混乱了,


满篇的


setXX


够不够混乱,


再来点不同类的


setXXA,setX XB


怎么样,你还想用迭代来“简便



”处理吗?)



并在


Qt



Example


里面被广泛的应用了,

< p>
并且在


Qt


开发里也应


注 意并应用的该机制。




使用了


Q_PROPERTY


宏(


Qt


对宏的应用可以说是相当精妙,


Qt


为 了能实


现在所有平台,所有


C++


编译 器都能应用,但又不能突破或改变


c++


的语法,巧

< p>
妙的应用了一系列宏,


QObject


里面



介绍了


Qt


的宏) 在类里使用该宏定义可以改变的属性,然后在功能类里同过该


宏来确定属性进行处理,极 大的提高了代码的重用性。



< br>动态


Properties



D ynamic


Properties



< p>


Properties



Value


正确


则改变


Value< /p>


,返回


True


,若

Properties


正确


Value

错误则不改变


Value


返回


Fa lse


,若


Properties


和< /p>


Value


都错误,


< br>则增加新的


Properties


并赋

< br>Vlaue


返回


False


(< /p>


Properties


正确指名称正确,


Value


正确指类型正确)。



8.*


间接对象技术“Meta


-


Object System”这技术可以通过父类指针来

< br>操纵子类的对象,并且提供实时得到对象类名和


Property


,除了


c++


本身的


dyna mic_cast


提供了


qobject_cast

< p>
进行



转型


(转型失败返 回


0




对于 熟悉


OO


的这部分可以看做上下转型那些,


JAVA


里的


getClass instance



这部分的实现基础有


3


个方面


a.


单根 继承于


QObject


(单根继承都流行


这种功能,并且可以用


QObject


指针指向任意一个对象 )


b.Q_OBJECT


宏(可以


方 便使用


Properties



c.


间接对象



编译(“Meta


-


Object C ompiler”,这样就与


c++


整合到了一起)

< p>


9. #include


直接包括了所有类库



10. new


出来的对象可以


->setObjectName(< /p>


11.


编译较慢



12. enum Qt::GlobalColor


可以设定颜色



13. stickman


被闪电击中


//


例 子不仅仅是例子,写那些例子的人很认真



14.


QtGui


部分


QPointF


坐标类


QPixmap


位图类


QGraphicsPixmapItem

< p>
提供位


图类的类


QGraphicsScene


显示图像类(


JAVAcontainer



QGraphicsItem class is the base class for all graphical items in


a QGraphicsScene.


QGraphicsEllipseItem provides an ellipse item


QGraphicsLineItem provides a line item


QGraphicsPathItem provides an arbitrary path item


QGraphicsPixmapItem provides a pixmap item


QGraphicsPolygonItem provides a polygon item


QGraphicsRectItem provides a rectangular item


QGraphicsSimpleTextItem provides a simple text label item


QGraphicsTextItem provides an advanced text browser item


The QGraphicsWidget class is the base class for all widget items in a


QGraphi csScene.



QWidget


类 似



The


QGraphicsView


class


provides


a


widget


for


displaying


the


contents


of


a QGraphicsScene.


Qt World//


短小例子




TARGET = abc


SOURCES +=



#include


#include


int main(int argc, char *argv[])

-


-


-


-


-


-


-


-



本文更新与2021-02-28 01:06,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/677370.html

Qt类的大致简介的相关文章