QT5 中有一个Implicit Sharing的概念,叫做隐式共享,许多QT中许多C++类用隐式数据共享来减少copy带来的资源占用问题。
当作为参数传递时,隐式数据共享是安全和高效的,因为仅仅是指向数据的指针进行传递,而数据只在有函数对它进行改写是才进行复制。(copy on write)
QT的如下类均用到了这个机理,如果不希望进行隐式共享,则需要多加注意了。
The QDBusPendingCall class refers to one pending asynchronous call |
|
The QDBusUnixFileDescriptor class holds one Unix file descriptor. |
|
The QBitmap class provides monochrome (1-bit depth) pixmaps. |
|
The QIcon class provides scalable icons in different modes and states. |
|
The QImage class provides a hardware-independent image representation that allows direct access to the pixel data, and can be used as a paint device. |
|
The QPicture class is a paint device that records and replays QPainter commands. |
|
The QPixmap class is an off-screen image representation that can be used as a paint device. |
|
The QCursor class provides a mouse cursor with an arbitrary shape. |
|
The QKeySequence class encapsulates a key sequence as used by shortcuts. |
|
The QPalette class contains color groups for each widget state. |
|
The QOpenGLDebugMessage class wraps an OpenGL debug message. |
|
The QBrush class defines the fill pattern of shapes drawn by QPainter. |
|
The QGradient class is used in combination with QBrush to specify gradient fills. |
|
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be constructed and reused. |
|
The QPen class defines how a QPainter should draw lines and outlines of shapes. |
|
The QPolygon class provides a vector of points using integer precision. |
|
The QPolygonF class provides a vector of points using floating point precision. |
|
The QRegion class specifies a clip region for a painter. |
|
|