QPicture 類

QPicture 類是描繪設備,用於記錄和重演 QPainter 命令。 更多...

頭: #include <QPicture>
qmake: QT += gui
繼承: QPaintDevice

公共函數

QPicture (const QPicture & pic )
QPicture (int formatVersion = -1)
QPicture & operator= (QPicture && other )
QPicture & operator= (const QPicture & p )
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 )
QDataStream & operator<< (QDataStream & s , const QPicture & r )
QDataStream & operator>> (QDataStream & s , QPicture & r )

詳細描述

圖片以獨立於平颱的格式將描繪器命令序列化到 IO 設備。它們有時被稱為元文件。

QPicture 使用專有二進製格式。不像很多窗口係統中的本機圖片 (元文件) 格式,QPicture 在其內容方麵沒有局限性。可以在 Widget 或像素圖中繪製一切 (如:字體、像素圖、區域、變換圖形、等),也可以存儲在圖片中。

QPicture 獨立於分辨率,即 QPicture 顯示在不同設備中 (例如 SVG、PDF、PS、打印機及屏幕) 看起來相同。例如,這是 WYSIWYG (所見即所得) 打印預覽需要的。QPicture 按係統默認 DPI (每英寸點數) 運行,且比例縮放描繪器能匹配從屬窗口係統的分辨率差異。

如何錄製圖片的範例:

        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 .

成員函數文檔編製

QPicture:: QPicture (const QPicture & pic )

構造副本為 pic .

此構造函數很快感謝 隱式共享 .

QPicture:: QPicture ( int formatVersion = -1)

構造空圖片。

The formatVersion 參數可以用於 create QPicture,其可以由采用早期 Qt 版本編譯的應用程序所讀取。

注意,formatVersion 默認 -1 錶示當前發行 (即:對於 Qt 4.0), formatVersion 為 7 如同 formatVersion 默認 -1。

Qt 4.0 不支持讀取由早期 Qt 版本生成的圖片。

QPicture &QPicture:: operator= ( QPicture && other )

移動賦值 other 到此 QPicture 實例。

該函數在 Qt 5.2 引入。

QPicture &QPicture:: operator= (const QPicture & p )

賦值圖片 p 到此圖片並返迴對此圖片的引用。

[虛擬] QPicture:: ~QPicture ()

銷毀圖片。

QRect QPicture:: boundingRect () const

返迴圖片的邊界矩形,或無效矩形若圖片不包含數據。

另請參閱 setBoundingRect ().

const char *QPicture:: data () const

返迴圖片數據指針。指針纔有效,直到此圖片調用下一非 const 函數。返迴指針為 0,若圖片不包含數據。

另請參閱 setData (), size (),和 isNull ().

bool QPicture:: isNull () const

返迴 true 若圖片不包含數據;否則返迴 false。

bool QPicture:: load (const QString & fileName , const char * format = nullptr)

加載圖片從文件指定通過 fileName 並返迴 true 若成功;否則為無效圖片並返迴 false .

Please note that the format parameter has been deprecated and will have no effect.

另請參閱 save ().

bool QPicture:: load ( QIODevice * dev , const char * format = nullptr)

這是重載函數。

dev 是用於加載的設備。

bool QPicture:: play ( QPainter * painter )

重演圖片使用 painter ,並返迴 true 若成功;否則返迴 false .

此函數做的準確如同 QPainter::drawPicture () 采用 (x, y) = (0, 0)。

bool QPicture:: save (const QString & fileName , const char * format = nullptr)

將圖片保存到文件指定通過 fileName 並返迴 true 若成功;否則返迴 false .

Please note that the format parameter has been deprecated and will have no effect.

另請參閱 load ().

bool QPicture:: save ( QIODevice * dev , const char * format = nullptr)

這是重載函數。

dev 是用於保存的設備。

void QPicture:: setBoundingRect (const QRect & r )

將圖片邊界矩形設為 r 。覆寫自動計算值。

另請參閱 boundingRect ().

[虛擬] void QPicture:: setData (const char * data , uint size )

直接設置圖片數據從 data and size 。此函數拷貝輸入數據。

另請參閱 data () 和 size ().

uint QPicture:: size () const

返迴圖片數據的大小。

另請參閱 data ().

void QPicture:: swap ( QPicture & other )

交換圖片 other 與此圖片。此操作很快且從不失敗。

該函數在 Qt 4.8 引入。

相關非成員

QDataStream & operator<< ( QDataStream & s , const QPicture & r )

寫入圖片 r 到流 s 並返迴流引用。

QDataStream & operator>> ( QDataStream & s , QPicture & r )

讀取圖片從流 s 到圖片 r 並返迴流引用。