Struct qt_gui::QPicture

source ·
#[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.

C++ documentation:

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

source

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.

C++ documentation:

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

See also setBoundingRect().

source

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).

C++ documentation:

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

source

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.

C++ documentation:

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 also setData(), size(), and isNull().

source

pub unsafe fn detach(&self)

Calls C++ function: void QPicture::detach().

source

pub unsafe fn dev_type(&self) -> c_int

Calls C++ function: virtual int QPicture::devType() const.

source

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().

C++ documentation:

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.

source

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().

C++ documentation:

Returns a list of picture formats that are supported for picture input.

See also outputFormats(), inputFormatList(), and QPictureIO.

source

pub unsafe fn is_detached(&self) -> bool

Calls C++ function: bool QPicture::isDetached() const.

source

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.

C++ documentation:

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

source

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 = …).

C++ documentation:

This is an overloaded function.

dev is the device to use for loading.

source

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 = …).

C++ documentation:

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().

source

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).

C++ documentation:

This is an overloaded function.

dev is the device to use for loading.

source

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).

C++ documentation:

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().

source

pub unsafe fn new_1a(format_version: c_int) -> CppBox<QPicture>

Constructs an empty picture.

Calls C++ function: [constructor] void QPicture::QPicture(int formatVersion = …).

C++ documentation:

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.

source

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().

C++ documentation:

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().

source

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).

C++ documentation:

Constructs a copy of pic.

This constructor is fast thanks to implicit sharing.

source

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().

C++ documentation:

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.

source

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().

C++ documentation:

Returns a list of picture formats that are supported for picture output.

See also inputFormats(), outputFormatList(), and QPictureIO.

source

pub unsafe fn paint_engine(&self) -> Ptr<QPaintEngine>

Calls C++ function: virtual QPaintEngine* QPicture::paintEngine() const.

source

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).

C++ documentation:

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.

See also load() and save().

source

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).

C++ documentation:

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).

source

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 = …).

C++ documentation:

This is an overloaded function.

dev is the device to use for saving.

source

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 = …).

C++ documentation:

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().

source

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).

C++ documentation:

This is an overloaded function.

dev is the device to use for saving.

source

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).

C++ documentation:

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().

source

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).

C++ documentation:

Sets the picture’s bounding rectangle to r. The automatically calculated value is overridden.

See also boundingRect().

source

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).

C++ documentation:

Sets the picture data directly from data and size. This function copies the input data.

See also data() and size().

source

pub unsafe fn size(&self) -> c_uint

Returns the size of the picture data.

Calls C++ function: unsigned int QPicture::size() const.

C++ documentation:

Returns the size of the picture data.

See also data().

source

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).

C++ documentation:

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>§

source

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.

C++ documentation:

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.

source

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.

C++ documentation:

Returns the bit depth (number of bit planes) of the paint device.

source

pub unsafe fn dev_type(&self) -> c_int

Calls C++ function: virtual int QPaintDevice::devType() const.

source

pub unsafe fn device_pixel_ratio(&self) -> c_int

Returns the device pixel ratio for device.

Calls C++ function: int QPaintDevice::devicePixelRatio() const.

C++ documentation:

Returns the device pixel ratio for device.

Common values are 1 for normal-dpi displays and 2 for high-dpi "retina" displays.

source

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.

C++ documentation:

Returns the device pixel ratio for the device as a floating point number.

This function was introduced in Qt 5.6.

source

pub unsafe fn height(&self) -> c_int

Returns the height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).

Calls C++ function: int QPaintDevice::height() const.

C++ documentation:

Returns the height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).

See also heightMM().

source

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.

C++ documentation:

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().

source

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.

C++ documentation:

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().

source

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.

C++ documentation:

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().

source

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.

C++ documentation:

Returns a pointer to the paint engine used for drawing on the device.

source

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.

C++ documentation:

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().

source

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.

C++ documentation:

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().

source

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.

C++ documentation:

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().

source

pub unsafe fn width(&self) -> c_int

Returns the width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).

Calls C++ function: int QPaintDevice::width() const.

C++ documentation:

Returns the width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).

See also widthMM().

source

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.

C++ documentation:

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

source§

unsafe fn delete(&self)

Destroys the picture.

Calls C++ function: virtual [destructor] void QPicture::~QPicture().

C++ documentation:

Destroys the picture.

source§

impl Data for QPicture

source§

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.

C++ documentation:

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 also setData(), size(), and isNull().

§

type Output = *const i8

Return type of data() function.
source§

impl Deref for QPicture

source§

fn deref(&self) -> &QPaintDevice

Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPicture* ptr).

§

type Target = QPaintDevice

The resulting type after dereferencing.
source§

impl DynamicCast<QPicture> for QPaintDevice

source§

unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPicture>

Calls C++ function: QPicture* dynamic_cast<QPicture*>(QPaintDevice* ptr).

source§

impl Size for QPicture

source§

unsafe fn size(&self) -> usize

Returns the size of the picture data.

Calls C++ function: unsigned int QPicture::size() const.

C++ documentation:

Returns the size of the picture data.

See also data().

source§

impl StaticDowncast<QPicture> for QPaintDevice

source§

unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPicture>

Calls C++ function: QPicture* static_cast<QPicture*>(QPaintDevice* ptr).

source§

impl StaticUpcast<QPaintDevice> for QPicture

source§

unsafe fn static_upcast(ptr: Ptr<QPicture>) -> Ptr<QPaintDevice>

Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPicture* ptr).

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.