qapplication







qwidget

The widget is the atom of the user interface: it receives mouse, keyboard and other events from the window system, and paints a representation of itself on the screen. Every widget is rectangular, and they are sorted in a Z-order. A widget is clipped by its parent and by the widgets in front of it.
A widget that is not embedded in a parent widget is called a window. Usually, windows have a frame and a title bar, although it is also possible to create windows without such decoration using suitable window flags. In Qt, QMainWindow and the various subclasses of QDialog are the most common window types.
qmainwindow:


qobject
qtmetamacros.h
#define Q_PROPERTY(...) QT_ANNOTATE_CLASS(qt_property, __VA_ARGS__) //(...)表示变长参数,__VA_ARGS__ 是一个特殊的预处理器变量,它代表 ... 中的所有参数
# define QT_ANNOTATE_CLASS(type, ...)
Q_PROPERTY(type name
(READ getFunction [WRITE setFunction] |
MEMBER memberName [(READ getFunction | WRITE setFunction)])
[RESET resetFunction]
[NOTIFY notifySignal]
[REVISION int | REVISION(int[, int])]
[DESIGNABLE bool]
[SCRIPTABLE bool]
[STORED bool]
[USER bool]
[BINDABLE bindableProperty]
[CONSTANT]
[FINAL]
[REQUIRED])
qt version
qt version history
qt releasing
qt tools
qt maintenance tools: 维护工具
基础
MOC meta object compliar
信号与槽
信号发生器:
只有 QObject 及其派生类才能使用信号和槽机制,且在类之中还需要使用 Q_OBJECT 宏。
信号由 moc 自动生成,不得在 .cpp 文件中实现。

信号创建规则:
信号使用 signals 关键字声明,在其后面有一个冒号“:”,在其前面不能有 public、private、protected 访问控制符,信号默认是 public 的。
信号只需像函数那样声明即可,其中可以有参数,参数的主要作用是用于和槽的通信,这就像普通函数的参数传递规则一样。信号虽然像函数,但是对他的调用方式不一样,信号需要使用 emit 关键字发射。
信号只需声明,不能对其进行定义,信号是由 moc 自动生成的。
信号的返回值只能是 void 类型的。
槽创建规则:
声明槽需要使用 slots 关键字,在其后面有一个冒号“:”,且槽需使用 public、private、protected 访问控制符之一。
槽就是一个普通的函数,可以像使用普通函数一样进行使用,槽与普通函数的主要区别是,槽可以与信号关联。
发射信号规则:
发射信号需要使用 emit 关键字,注意,在 emit 后面不需要冒号。
emit 发射的信号使用的语法与调用普通函数相同,比如有一个信号为 void f(int),则发送的语法为:emit f(3);
当信号被发射时,与其相关联的槽函数会被调用(注意:信号和槽需要使用
QObject::connect 函数进行关联之后,发射信号后才会调用相关联的槽函数)。
因为信号位于类之中,因此发射信号的位置需要位于该类的成员函数中或该
类能见到信号的标识符的位置。
信号和槽的关系:
槽的参数的类型需要与信号参数的类型相对应,
槽的参数不能多余信号的参数,因为若槽的参数更多,则多余的参数不能接收到信号传递过来的值,若在槽中使用了这些多余的无值的参数,就会产生错误。
若信号的参数多余槽的参数,则多余的参数将被忽略。
一个信号可以与多个槽关联,多个信号也可以与同一个槽关联,信号也可以关联到另一个信号上。
若一个信号关联到多个槽时,则发射信号时,槽函数按照关联的顺序依次执行。
若信号连接到另一个信号,则当第一个信号发射时,会立即发射第二个信号。
绘图
QObject Class
QQuickItem Class
layout items using the concept of anchors
qml type registration
QRect QPoint QColor
QColor::QColor(Qt::GlobalColor color)

QPoint(int xpos, int ypos)
QRect::QRect(const QPoint &topLeft, const QPoint &bottomRight)
QRect::QRect(const QPoint &topLeft, const QSize &size)
QBrush::QBrush(const QColor &color, Qt::BrushStyle style = Qt::SolidPattern)


浙公网安备 33010602011771号