#[repr(C)]pub struct QPicture { /* private fields */ }
Expand description
The QPicture class is a paint device that records and replays QPainter commands.
C++ class: QPicture
.
The QPicture class is a paint device that records and replays QPainter 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. 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.
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 the QPainter::begin() function.
Example of how to replay a picture:
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
Pictures can also be drawn using play(). Some basic data about a picture is available, for example, size(), isNull() and boundingRect().
Implementations§
source§impl QPicture
impl QPicture
sourcepub unsafe fn bounding_rect(&self) -> CppBox<QRect>
pub unsafe fn bounding_rect(&self) -> CppBox<QRect>
Returns the picture's bounding rectangle or an invalid rectangle if the picture contains no data.
Calls C++ function: QRect QPicture::boundingRect() const
.
Returns the picture’s bounding rectangle or an invalid rectangle if the picture contains no data.
See also setBoundingRect().
sourcepub unsafe fn copy_from(&self, p: impl CastInto<Ref<QPicture>>) -> Ref<QPicture>
pub unsafe fn copy_from(&self, p: impl CastInto<Ref<QPicture>>) -> Ref<QPicture>
Assigns picture p to this picture and returns a reference to this picture.
Calls C++ function: QPicture& QPicture::operator=(const QPicture& p)
.
Assigns picture p to this picture and returns a reference to this picture.
sourcepub unsafe fn data(&self) -> *const c_char
pub unsafe fn data(&self) -> *const c_char
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.
Calls C++ function: const char* QPicture::data() const
.
sourcepub unsafe fn dev_type(&self) -> c_int
pub unsafe fn dev_type(&self) -> c_int
Calls C++ function: virtual int QPicture::devType() const
.
sourcepub unsafe fn input_format_list() -> CppBox<QStringList>
pub unsafe fn input_format_list() -> CppBox<QStringList>
Returns a list of picture formats that are supported for picture input.
Calls C++ function: static QStringList QPicture::inputFormatList()
.
Returns a list of picture formats that are supported for picture input.
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
QStringList list = QPicture::inputFormatList(); foreach (const QString &string, list) myProcessing(string);
See also outputFormatList(), inputFormats(), and QPictureIO.
sourcepub unsafe fn input_formats() -> CppBox<QListOfQByteArray>
pub unsafe fn input_formats() -> CppBox<QListOfQByteArray>
Returns a list of picture formats that are supported for picture input.
Calls C++ function: static QList<QByteArray> QPicture::inputFormats()
.
Returns a list of picture formats that are supported for picture input.
See also outputFormats(), inputFormatList(), and QPictureIO.
sourcepub unsafe fn is_detached(&self) -> bool
pub unsafe fn is_detached(&self) -> bool
Calls C++ function: bool QPicture::isDetached() const
.
sourcepub unsafe fn is_null(&self) -> bool
pub unsafe fn is_null(&self) -> bool
Returns true
if the picture contains no data; otherwise returns false.
Calls C++ function: bool QPicture::isNull() const
.
Returns true
if the picture contains no data; otherwise returns false.
sourcepub unsafe fn load_q_io_device_char(
&self,
dev: impl CastInto<Ptr<QIODevice>>,
format: *const c_char
) -> bool
pub unsafe fn load_q_io_device_char( &self, dev: impl CastInto<Ptr<QIODevice>>, format: *const c_char ) -> bool
This is an overloaded function.
Calls C++ function: bool QPicture::load(QIODevice* dev, const char* format = …)
.
This is an overloaded function.
dev is the device to use for loading.
sourcepub unsafe fn load_q_string_char(
&self,
file_name: impl CastInto<Ref<QString>>,
format: *const c_char
) -> bool
pub unsafe fn load_q_string_char( &self, file_name: impl CastInto<Ref<QString>>, format: *const c_char ) -> bool
Loads a picture from the file specified by fileName and returns true if successful; otherwise invalidates the picture and returns false
.
Calls C++ function: bool QPicture::load(const QString& fileName, const char* format = …)
.
Loads a picture from the file specified by fileName and returns true if successful; otherwise invalidates the picture and returns false
.
Please note that the format parameter has been deprecated and will have no effect.
See also save().
sourcepub unsafe fn load_q_io_device(
&self,
dev: impl CastInto<Ptr<QIODevice>>
) -> bool
pub unsafe fn load_q_io_device( &self, dev: impl CastInto<Ptr<QIODevice>> ) -> bool
This is an overloaded function.
Calls C++ function: bool QPicture::load(QIODevice* dev)
.
This is an overloaded function.
dev is the device to use for loading.
sourcepub unsafe fn load_q_string(
&self,
file_name: impl CastInto<Ref<QString>>
) -> bool
pub unsafe fn load_q_string( &self, file_name: impl CastInto<Ref<QString>> ) -> bool
Loads a picture from the file specified by fileName and returns true if successful; otherwise invalidates the picture and returns false
.
Calls C++ function: bool QPicture::load(const QString& fileName)
.
Loads a picture from the file specified by fileName and returns true if successful; otherwise invalidates the picture and returns false
.
Please note that the format parameter has been deprecated and will have no effect.
See also save().
sourcepub unsafe fn new_1a(format_version: c_int) -> CppBox<QPicture>
pub unsafe fn new_1a(format_version: c_int) -> CppBox<QPicture>
Constructs an empty picture.
Calls C++ function: [constructor] void QPicture::QPicture(int formatVersion = …)
.
Constructs an empty picture.
The formatVersion parameter may be used to create a QPicture 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.
sourcepub unsafe fn new_0a() -> CppBox<QPicture>
pub unsafe fn new_0a() -> CppBox<QPicture>
The QPicture class is a paint device that records and replays QPainter commands.
Calls C++ function: [constructor] void QPicture::QPicture()
.
The QPicture class is a paint device that records and replays QPainter 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. 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.
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 the QPainter::begin() function.
Example of how to replay a picture:
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
Pictures can also be drawn using play(). Some basic data about a picture is available, for example, size(), isNull() and boundingRect().
sourcepub unsafe fn new_copy(arg1: impl CastInto<Ref<QPicture>>) -> CppBox<QPicture>
pub unsafe fn new_copy(arg1: impl CastInto<Ref<QPicture>>) -> CppBox<QPicture>
Constructs a copy of pic.
Calls C++ function: [constructor] void QPicture::QPicture(const QPicture& arg1)
.
Constructs a copy of pic.
This constructor is fast thanks to implicit sharing.
sourcepub unsafe fn output_format_list() -> CppBox<QStringList>
pub unsafe fn output_format_list() -> CppBox<QStringList>
Returns a list of picture formats that are supported for picture output.
Calls C++ function: static QStringList QPicture::outputFormatList()
.
Returns a list of picture formats that are supported for picture output.
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
QStringList list = QPicture::outputFormatList(); foreach (const QString &string, list) myProcessing(string);
See also inputFormatList(), outputFormats(), and QPictureIO.
sourcepub unsafe fn output_formats() -> CppBox<QListOfQByteArray>
pub unsafe fn output_formats() -> CppBox<QListOfQByteArray>
Returns a list of picture formats that are supported for picture output.
Calls C++ function: static QList<QByteArray> QPicture::outputFormats()
.
Returns a list of picture formats that are supported for picture output.
See also inputFormats(), outputFormatList(), and QPictureIO.
sourcepub unsafe fn paint_engine(&self) -> Ptr<QPaintEngine>
pub unsafe fn paint_engine(&self) -> Ptr<QPaintEngine>
Calls C++ function: virtual QPaintEngine* QPicture::paintEngine() const
.
sourcepub unsafe fn picture_format(
file_name: impl CastInto<Ref<QString>>
) -> *const c_char
pub unsafe fn picture_format( file_name: impl CastInto<Ref<QString>> ) -> *const c_char
Returns a string that specifies the picture format of the file fileName, or 0 if the file cannot be read or if the format is not recognized.
Calls C++ function: static const char* QPicture::pictureFormat(const QString& fileName)
.
sourcepub unsafe fn play(&self, p: impl CastInto<Ptr<QPainter>>) -> bool
pub unsafe fn play(&self, p: impl CastInto<Ptr<QPainter>>) -> bool
Replays the picture using painter, and returns true
if successful; otherwise returns false
.
Calls C++ function: bool QPicture::play(QPainter* p)
.
Replays the picture using painter, and returns true
if successful; otherwise returns false
.
This function does exactly the same as QPainter::drawPicture() with (x, y) = (0, 0).
sourcepub unsafe fn save_q_io_device_char(
&self,
dev: impl CastInto<Ptr<QIODevice>>,
format: *const c_char
) -> bool
pub unsafe fn save_q_io_device_char( &self, dev: impl CastInto<Ptr<QIODevice>>, format: *const c_char ) -> bool
This is an overloaded function.
Calls C++ function: bool QPicture::save(QIODevice* dev, const char* format = …)
.
This is an overloaded function.
dev is the device to use for saving.
sourcepub unsafe fn save_q_string_char(
&self,
file_name: impl CastInto<Ref<QString>>,
format: *const c_char
) -> bool
pub unsafe fn save_q_string_char( &self, file_name: impl CastInto<Ref<QString>>, format: *const c_char ) -> bool
Saves a picture to the file specified by fileName and returns true if successful; otherwise returns false
.
Calls C++ function: bool QPicture::save(const QString& fileName, const char* format = …)
.
Saves a picture to the file specified by fileName and returns true if successful; otherwise returns false
.
Please note that the format parameter has been deprecated and will have no effect.
See also load().
sourcepub unsafe fn save_q_io_device(
&self,
dev: impl CastInto<Ptr<QIODevice>>
) -> bool
pub unsafe fn save_q_io_device( &self, dev: impl CastInto<Ptr<QIODevice>> ) -> bool
This is an overloaded function.
Calls C++ function: bool QPicture::save(QIODevice* dev)
.
This is an overloaded function.
dev is the device to use for saving.
sourcepub unsafe fn save_q_string(
&self,
file_name: impl CastInto<Ref<QString>>
) -> bool
pub unsafe fn save_q_string( &self, file_name: impl CastInto<Ref<QString>> ) -> bool
Saves a picture to the file specified by fileName and returns true if successful; otherwise returns false
.
Calls C++ function: bool QPicture::save(const QString& fileName)
.
Saves a picture to the file specified by fileName and returns true if successful; otherwise returns false
.
Please note that the format parameter has been deprecated and will have no effect.
See also load().
sourcepub unsafe fn set_bounding_rect(&self, r: impl CastInto<Ref<QRect>>)
pub unsafe fn set_bounding_rect(&self, r: impl CastInto<Ref<QRect>>)
Sets the picture's bounding rectangle to r. The automatically calculated value is overridden.
Calls C++ function: void QPicture::setBoundingRect(const QRect& r)
.
Sets the picture’s bounding rectangle to r. The automatically calculated value is overridden.
See also boundingRect().
sourcepub unsafe fn set_data(&self, data: *const c_char, size: c_uint)
pub unsafe fn set_data(&self, data: *const c_char, size: c_uint)
Sets the picture data directly from data and size. This function copies the input data.
Calls C++ function: virtual void QPicture::setData(const char* data, unsigned int size)
.
sourcepub unsafe fn size(&self) -> c_uint
pub unsafe fn size(&self) -> c_uint
Returns the size of the picture data.
Calls C++ function: unsigned int QPicture::size() const
.
Returns the size of the picture data.
See also data().
sourcepub unsafe fn swap(&self, other: impl CastInto<Ref<QPicture>>)
pub unsafe fn swap(&self, other: impl CastInto<Ref<QPicture>>)
Swaps picture other with this picture. This operation is very fast and never fails.
Calls C++ function: void QPicture::swap(QPicture& other)
.
Swaps picture other with this picture. This operation is very fast and never fails.
This function was introduced in Qt 4.8.
Methods from Deref<Target = QPaintDevice>§
sourcepub unsafe fn color_count(&self) -> c_int
pub unsafe fn color_count(&self) -> c_int
Returns the number of different colors available for the paint device. If the number of colors available is too great to be represented by the int data type, then INT_MAX will be returned instead.
Calls C++ function: int QPaintDevice::colorCount() const
.
Returns the number of different colors available for the paint device. If the number of colors available is too great to be represented by the int data type, then INT_MAX will be returned instead.
sourcepub unsafe fn depth(&self) -> c_int
pub unsafe fn depth(&self) -> c_int
Returns the bit depth (number of bit planes) of the paint device.
Calls C++ function: int QPaintDevice::depth() const
.
Returns the bit depth (number of bit planes) of the paint device.
sourcepub unsafe fn dev_type(&self) -> c_int
pub unsafe fn dev_type(&self) -> c_int
Calls C++ function: virtual int QPaintDevice::devType() const
.
sourcepub unsafe fn device_pixel_ratio(&self) -> c_int
pub unsafe fn device_pixel_ratio(&self) -> c_int
Returns the device pixel ratio for device.
Calls C++ function: int QPaintDevice::devicePixelRatio() const
.
Returns the device pixel ratio for device.
Common values are 1 for normal-dpi displays and 2 for high-dpi "retina" displays.
sourcepub unsafe fn device_pixel_ratio_f(&self) -> c_double
pub unsafe fn device_pixel_ratio_f(&self) -> c_double
Returns the device pixel ratio for the device as a floating point number.
Calls C++ function: double QPaintDevice::devicePixelRatioF() const
.
Returns the device pixel ratio for the device as a floating point number.
This function was introduced in Qt 5.6.
sourcepub unsafe fn height(&self) -> c_int
pub unsafe fn height(&self) -> c_int
sourcepub unsafe fn height_m_m(&self) -> c_int
pub unsafe fn height_m_m(&self) -> c_int
Returns the height of the paint device in millimeters. Due to platform limitations it may not be possible to use this function to determine the actual physical size of a widget on the screen.
Calls C++ function: int QPaintDevice::heightMM() const
.
Returns the height of the paint device in millimeters. Due to platform limitations it may not be possible to use this function to determine the actual physical size of a widget on the screen.
See also height().
sourcepub unsafe fn logical_dpi_x(&self) -> c_int
pub unsafe fn logical_dpi_x(&self) -> c_int
Returns the horizontal resolution of the device in dots per inch, which is used when computing font sizes. For X11, this is usually the same as could be computed from widthMM().
Calls C++ function: int QPaintDevice::logicalDpiX() const
.
Returns the horizontal resolution of the device in dots per inch, which is used when computing font sizes. For X11, this is usually the same as could be computed from widthMM().
Note that if the logicalDpiX() doesn't equal the physicalDpiX(), the corresponding QPaintEngine must handle the resolution mapping.
See also logicalDpiY() and physicalDpiX().
sourcepub unsafe fn logical_dpi_y(&self) -> c_int
pub unsafe fn logical_dpi_y(&self) -> c_int
Returns the vertical resolution of the device in dots per inch, which is used when computing font sizes. For X11, this is usually the same as could be computed from heightMM().
Calls C++ function: int QPaintDevice::logicalDpiY() const
.
Returns the vertical resolution of the device in dots per inch, which is used when computing font sizes. For X11, this is usually the same as could be computed from heightMM().
Note that if the logicalDpiY() doesn't equal the physicalDpiY(), the corresponding QPaintEngine must handle the resolution mapping.
See also logicalDpiX() and physicalDpiY().
sourcepub unsafe fn paint_engine(&self) -> Ptr<QPaintEngine>
pub unsafe fn paint_engine(&self) -> Ptr<QPaintEngine>
Returns a pointer to the paint engine used for drawing on the device.
Calls C++ function: pure virtual QPaintEngine* QPaintDevice::paintEngine() const
.
Returns a pointer to the paint engine used for drawing on the device.
sourcepub unsafe fn painting_active(&self) -> bool
pub unsafe fn painting_active(&self) -> bool
Returns true
if the device is currently being painted on, i.e. someone has called QPainter::begin() but not yet called QPainter::end() for this device; otherwise returns false
.
Calls C++ function: bool QPaintDevice::paintingActive() const
.
Returns true
if the device is currently being painted on, i.e. someone has called QPainter::begin() but not yet called QPainter::end() for this device; otherwise returns false
.
See also QPainter::isActive().
sourcepub unsafe fn physical_dpi_x(&self) -> c_int
pub unsafe fn physical_dpi_x(&self) -> c_int
Returns the horizontal resolution of the device in dots per inch. For example, when printing, this resolution refers to the physical printer's resolution. The logical DPI on the other hand, refers to the resolution used by the actual paint engine.
Calls C++ function: int QPaintDevice::physicalDpiX() const
.
Returns the horizontal resolution of the device in dots per inch. For example, when printing, this resolution refers to the physical printer’s resolution. The logical DPI on the other hand, refers to the resolution used by the actual paint engine.
Note that if the physicalDpiX() doesn't equal the logicalDpiX(), the corresponding QPaintEngine must handle the resolution mapping.
See also physicalDpiY() and logicalDpiX().
sourcepub unsafe fn physical_dpi_y(&self) -> c_int
pub unsafe fn physical_dpi_y(&self) -> c_int
Returns the horizontal resolution of the device in dots per inch. For example, when printing, this resolution refers to the physical printer's resolution. The logical DPI on the other hand, refers to the resolution used by the actual paint engine.
Calls C++ function: int QPaintDevice::physicalDpiY() const
.
Returns the horizontal resolution of the device in dots per inch. For example, when printing, this resolution refers to the physical printer’s resolution. The logical DPI on the other hand, refers to the resolution used by the actual paint engine.
Note that if the physicalDpiY() doesn't equal the logicalDpiY(), the corresponding QPaintEngine must handle the resolution mapping.
See also physicalDpiX() and logicalDpiY().
sourcepub unsafe fn width(&self) -> c_int
pub unsafe fn width(&self) -> c_int
sourcepub unsafe fn width_m_m(&self) -> c_int
pub unsafe fn width_m_m(&self) -> c_int
Returns the width of the paint device in millimeters. Due to platform limitations it may not be possible to use this function to determine the actual physical size of a widget on the screen.
Calls C++ function: int QPaintDevice::widthMM() const
.
Returns the width of the paint device in millimeters. Due to platform limitations it may not be possible to use this function to determine the actual physical size of a widget on the screen.
See also width().
Trait Implementations§
source§impl CppDeletable for QPicture
impl CppDeletable for QPicture
source§impl Data for QPicture
impl Data for QPicture
source§impl Deref for QPicture
impl Deref for QPicture
source§fn deref(&self) -> &QPaintDevice
fn deref(&self) -> &QPaintDevice
Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPicture* ptr)
.
§type Target = QPaintDevice
type Target = QPaintDevice
source§impl DynamicCast<QPicture> for QPaintDevice
impl DynamicCast<QPicture> for QPaintDevice
source§unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPicture>
unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPicture>
Calls C++ function: QPicture* dynamic_cast<QPicture*>(QPaintDevice* ptr)
.
source§impl StaticDowncast<QPicture> for QPaintDevice
impl StaticDowncast<QPicture> for QPaintDevice
source§unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPicture>
unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPicture>
Calls C++ function: QPicture* static_cast<QPicture*>(QPaintDevice* ptr)
.
source§impl StaticUpcast<QPaintDevice> for QPicture
impl StaticUpcast<QPaintDevice> for QPicture
source§unsafe fn static_upcast(ptr: Ptr<QPicture>) -> Ptr<QPaintDevice>
unsafe fn static_upcast(ptr: Ptr<QPicture>) -> Ptr<QPaintDevice>
Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPicture* ptr)
.