The QPicture 類是描繪設備,它記錄並重演 QPainter 命令。 更多...
| 頭: | #include <QPicture> |
| qmake: | QT += gui |
| 繼承: | QPaintDevice |
| QPicture (int formatVersion = -1) | |
| QPicture (const QPicture & pic ) | |
| virtual | ~QPicture () |
| QRect | boundingRect () const |
| const char * | data () const |
| bool | isNull () const |
| bool | load (const QString & fileName , const char * format = nullptr) |
| bool | load (QIODevice * dev , const char * format = nullptr) |
| bool | play (QPainter * painter ) |
| bool | save (const QString & fileName , const char * format = nullptr) |
| bool | save (QIODevice * dev , const char * format = nullptr) |
| void | setBoundingRect (const QRect & r ) |
| virtual void | setData (const char * data , uint size ) |
| uint | size () const |
| void | swap (QPicture & other ) |
| QPicture & | operator= (const QPicture & p ) |
| QPicture & | operator= (QPicture && other ) |
| QDataStream & | operator<< (QDataStream & s , const QPicture & r ) |
| QDataStream & | operator>> (QDataStream & s , QPicture & r ) |
The QPicture 類是描繪設備,它記錄並重演 QPainter 命令。
圖片以獨立於平颱的格式將描繪器命令序列化到 IO 設備。它們有時被稱為元文件。
QPicture 使用專有二進製格式。不像很多窗口係統中的本機圖片 (元文件) 格式,QPicture 在其內容方麵沒有局限性。可以在 Widget 或像素圖中繪製一切 (如:字體、像素圖、區域、變換圖形、等),也可以存儲在圖片中。
QPicture is resolution independent, i.e. a QPicture can be displayed on different devices (for example svg, pdf, ps, printer and screen) looking the same. This is, for instance, needed for WYSIWYG print preview. QPicture runs in the default system dpi, and scales the painter to match differences in resolution depending on the window system.
如何錄製圖片的範例:
QPicture picture;
QPainter painter;
painter.begin(&picture); // paint in picture
painter.drawEllipse(10,20, 80,70); // draw an ellipse
painter.end(); // painting done
picture.save("drawing.pic"); // save picture
注意,描繪器命令列錶會被重置當每次調用 QPainter::begin () 函數。
如何重演圖片的範例:
QPicture picture;
picture.load("drawing.pic"); // load picture
QPainter painter;
painter.begin(&myImage); // paint in myImage
painter.drawPicture(0, 0, picture); // draw the picture at (0,0)
painter.end(); // painting done
也可以繪製圖片使用 play ()。關於圖片的一些基本數據是可用的,例如, size (), isNull () 和 boundingRect ().
另請參閱 QMovie .
構造空圖片。
The formatVersion 參數可以用於 create a QPicture that can be read by applications that are compiled with earlier versions of Qt.
注意,formatVersion 默認 -1 錶示當前發行 (即:對於 Qt 4.0), formatVersion 為 7 如同 formatVersion 默認 -1。
Qt 4.0 不支持讀取由早期 Qt 版本生成的圖片。
構造副本為 pic .
此構造函數很快感謝 隱式共享 .
[虛擬]
QPicture::
~QPicture
()
銷毀圖片。
返迴圖片的邊界矩形,或無效矩形若圖片不包含數據。
另請參閱 setBoundingRect ().
返迴圖片數據指針。指針纔有效,直到此圖片調用下一非 const 函數。返迴指針為 0,若圖片不包含數據。
另請參閱 setData (), size (),和 isNull ().
返迴
true
若圖片不包含數據;否則返迴 false。
加載圖片從文件指定通過
fileName
並返迴 true 若成功;否則為無效圖片並返迴
false
.
Please note that the format parameter has been deprecated and will have no effect.
另請參閱 save ().
這是重載函數。
dev 是用於加載的設備。
重演圖片使用
painter
,並返迴
true
若成功;否則返迴
false
.
此函數做的準確如同 QPainter::drawPicture () 采用 (x, y) = (0, 0)。
將圖片保存到文件指定通過
fileName
並返迴 true 若成功;否則返迴
false
.
Please note that the format parameter has been deprecated and will have no effect.
另請參閱 load ().
這是重載函數。
dev 是用於保存的設備。
將圖片邊界矩形設為 r 。覆寫自動計算值。
另請參閱 boundingRect ().
[虛擬]
void
QPicture::
setData
(const
char
*
data
,
uint
size
)
直接設置圖片數據從 data and size 。此函數拷貝輸入數據。
返迴圖片數據的大小。
另請參閱 data ().
交換圖片 other 與此圖片。此操作很快且從不失敗。
該函數在 Qt 4.8 引入。
賦值圖片 p 到此圖片並返迴對此圖片的引用。
移動賦值 other 到此 QPicture 實例。
該函數在 Qt 5.2 引入。
寫入圖片 r 到流 s 並返迴流引用。
讀取圖片從流 s 到圖片 r 並返迴流引用。