Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QPicture Class

TheQPicture class is a paint device that records and replaysQPainter commands.More...

Header:#include <QPicture>
Inherits:QPaintDevice
Inherited By:

Q3Picture

Public Functions

QPicture(int formatVersion = -1)
QPicture(const QPicture & pic)
~QPicture()
QRectboundingRect() const
const char *data() const
boolisNull() const
boolload(const QString & fileName, const char * format = 0)
boolload(QIODevice * dev, const char * format = 0)
boolplay(QPainter * painter)
boolsave(const QString & fileName, const char * format = 0)
boolsave(QIODevice * dev, const char * format = 0)
voidsetBoundingRect(const QRect & r)
virtual voidsetData(const char * data, uint size)
uintsize() const
voidswap(QPicture & other)
QPicture &operator=(const QPicture & p)
QPicture &operator=(QPicture && other)

Related Non-Members

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

Additional Inherited Members

Detailed Description

TheQPicture class is a paint device that records and replaysQPainter commands.

A picture serializes painter commands to an IO device in a platform-independent format. They are sometimes referred to as meta-files.

Qt pictures use a proprietary binary format. Unlike native picture (meta-file) formats on many window systems, Qt pictures have no limitations regarding their contents. Everything that can be painted on a widget or pixmap (e.g., fonts, pixmaps, regions, transformed graphics, etc.) can also be stored in a picture.

QPicture is resolution independent, i.e. aQPicture 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.

Example of how to record a picture:

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

Note that the list of painter commands is reset on each call to theQPainter::begin() function.

Example of how to replay a picture:

QPicture picture;        picture.load("drawing.pic");// load pictureQPainter painter;        painter.begin(&myImage);// paint in myImage        painter.drawPicture(0,0, picture);// draw the picture at (0,0)        painter.end();// painting done

Pictures can also be drawn usingplay(). Some basic data about a picture is available, for example,size(),isNull() andboundingRect().

See alsoQMovie.

Member Function Documentation

QPicture::QPicture(int formatVersion = -1)

Constructs an empty picture.

TheformatVersion parameter may be used tocreate aQPicture that can be read by applications that are compiled with earlier versions of Qt.

Note that the default formatVersion is -1 which signifies the current release, i.e. for Qt 4.0 a formatVersion of 7 is the same as the default formatVersion of -1.

Reading pictures generated by earlier versions of Qt is not supported in Qt 4.0.

QPicture::QPicture(constQPicture & pic)

Constructs a copy ofpic.

This constructor is fast thanks toimplicit sharing.

QPicture::~QPicture()

Destroys the picture.

QRect QPicture::boundingRect() const

Returns the picture's bounding rectangle or an invalid rectangle if the picture contains no data.

See alsosetBoundingRect().

constchar * QPicture::data() const

Returns a pointer to the picture data. The pointer is only valid until the next non-const function is called on this picture. The returned pointer is 0 if the picture contains no data.

See alsosetData(),size(), andisNull().

bool QPicture::isNull() const

Returns true if the picture contains no data; otherwise returns false.

bool QPicture::load(constQString & fileName, constchar * format = 0)

Loads a picture from the file specified byfileName and returns true if successful; otherwise returns false.

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

See alsosave().

bool QPicture::load(QIODevice * dev, constchar * format = 0)

This is an overloaded function.

dev is the device to use for loading.

bool QPicture::play(QPainter * painter)

Replays the picture usingpainter, and returns true if successful; otherwise returns false.

This function does exactly the same asQPainter::drawPicture() with (x, y) = (0, 0).

bool QPicture::save(constQString & fileName, constchar * format = 0)

Saves a picture to the file specified byfileName and returns true if successful; otherwise returns false.

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

See alsoload().

bool QPicture::save(QIODevice * dev, constchar * format = 0)

This is an overloaded function.

dev is the device to use for saving.

void QPicture::setBoundingRect(constQRect & r)

Sets the picture's bounding rectangle tor. The automatically calculated value is overridden.

See alsoboundingRect().

[virtual]void QPicture::setData(constchar * data,uint size)

Sets the picture data directly fromdata andsize. This function copies the input data.

See alsodata() andsize().

uint QPicture::size() const

Returns the size of the picture data.

See alsodata().

void QPicture::swap(QPicture & other)

Swaps pictureother with this picture. This operation is very fast and never fails.

This function was introduced in Qt 4.8.

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

Assigns picturep to this picture and returns a reference to this picture.

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

Related Non-Members

QDataStream &operator<<(QDataStream & s, constQPicture & r)

Writes picturer to the streams and returns a reference to the stream.

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

Reads a picture from the streams into picturer and returns a reference to the stream.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp