[][src]Struct qt_gui::QImageIOPlugin

#[repr(C)]pub struct QImageIOPlugin { /* fields omitted */ }

The QImageIOPlugin class defines an interface for writing an image format plugin.

C++ class: QImageIOPlugin.

C++ documentation:

The QImageIOPlugin class defines an interface for writing an image format plugin.

QImageIOPlugin is a factory for creating QImageIOHandler objects, which are used internally by QImageReader and QImageWriter to add support for different image formats to Qt.

Writing an image I/O plugin is achieved by subclassing this base class, reimplementing the pure virtual functions capabilities() and create(), and exporting the class with the Q_PLUGIN_METADATA() macro. See How to Create Qt Plugins for details.

An image format plugin can support three capabilities: reading (CanRead), writing (CanWrite) and incremental reading (CanReadIncremental). Reimplement capabilities() in you subclass to expose the capabilities of your image format.

create() should create an instance of your QImageIOHandler subclass, with the provided device and format properly set, and return this handler.

The json metadata file for the plugin needs to contain information about the image formats the plugins supports, together with the corresponding MIME types (one for each format). For a jpeg plugin, this could, for example, look as follows:

{ "Keys": [ "jpg", "jpeg" ], "MimeTypes": [ "image/jpeg", "image/jpeg" ] }

Different plugins can support different capabilities. For example, you may have one plugin that supports reading the GIF format, and another that supports writing. Qt will select the correct plugin for the job, depending on the return value of capabilities(). If several plugins support the same capability, Qt will select one arbitrarily.

Methods

impl QImageIOPlugin[src]

pub unsafe fn capabilities(
    &self,
    device: impl CastInto<Ptr<QIODevice>>,
    format: impl CastInto<Ref<QByteArray>>
) -> QFlags<Capability>
[src]

Returns the capabilities of the plugin, based on the data in device and the format format. If device is 0, it should simply report whether the format can be read or written. Otherwise, it should attempt to determine whether the given format (or any format supported by the plugin if format is empty) can be read from or written to device. It should do this without changing the state of device (typically by using QIODevice::peek()).

Calls C++ function: pure virtual QFlags<QImageIOPlugin::Capability> QImageIOPlugin::capabilities(QIODevice* device, const QByteArray& format) const.

C++ documentation:

Returns the capabilities of the plugin, based on the data in device and the format format. If device is 0, it should simply report whether the format can be read or written. Otherwise, it should attempt to determine whether the given format (or any format supported by the plugin if format is empty) can be read from or written to device. It should do this without changing the state of device (typically by using QIODevice::peek()).

For example, if the QImageIOPlugin supports the BMP format, format is either empty or "bmp", and the data in the device starts with the characters "BM", this function should return CanRead. If format is "bmp", device is 0 and the handler supports both reading and writing, this function should return CanRead | CanWrite.

Format names are always given in lower case.

pub unsafe fn create_2a(
    &self,
    device: impl CastInto<Ptr<QIODevice>>,
    format: impl CastInto<Ref<QByteArray>>
) -> Ptr<QImageIOHandler>
[src]

Creates and returns a QImageIOHandler subclass, with device and format set. The format must come from the values listed in the "Keys" entry in the plugin metadata, or be empty. If it is empty, the data in device must have been recognized by the capabilities() method (with a likewise empty format).

Calls C++ function: pure virtual QImageIOHandler* QImageIOPlugin::create(QIODevice* device, const QByteArray& format = …) const.

C++ documentation:

Creates and returns a QImageIOHandler subclass, with device and format set. The format must come from the values listed in the "Keys" entry in the plugin metadata, or be empty. If it is empty, the data in device must have been recognized by the capabilities() method (with a likewise empty format).

Format names are always given in lower case.

pub unsafe fn create_1a(
    &self,
    device: impl CastInto<Ptr<QIODevice>>
) -> Ptr<QImageIOHandler>
[src]

Creates and returns a QImageIOHandler subclass, with device and format set. The format must come from the values listed in the "Keys" entry in the plugin metadata, or be empty. If it is empty, the data in device must have been recognized by the capabilities() method (with a likewise empty format).

Calls C++ function: pure virtual QImageIOHandler* QImageIOPlugin::create(QIODevice* device) const.

C++ documentation:

Creates and returns a QImageIOHandler subclass, with device and format set. The format must come from the values listed in the "Keys" entry in the plugin metadata, or be empty. If it is empty, the data in device must have been recognized by the capabilities() method (with a likewise empty format).

Format names are always given in lower case.

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QImageIOPlugin::metaObject() const.

pub unsafe fn qt_metacall(
    &self,
    arg1: Call,
    arg2: c_int,
    arg3: *mut *mut c_void
) -> c_int
[src]

Calls C++ function: virtual int QImageIOPlugin::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void[src]

Calls C++ function: virtual void* QImageIOPlugin::qt_metacast(const char* arg1).

pub unsafe fn static_meta_object() -> Ref<QMetaObject>[src]

Returns a reference to the staticMetaObject field.

pub unsafe fn tr(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QImageIOPlugin::tr(const char* s, const char* c, int n).

pub unsafe fn tr_utf8(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QImageIOPlugin::trUtf8(const char* s, const char* c, int n).

Trait Implementations

impl CppDeletable for QImageIOPlugin[src]

unsafe fn delete(&self)[src]

Destroys the picture format plugin.

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

C++ documentation:

Destroys the picture format plugin.

You never have to call this explicitly. Qt destroys a plugin automatically when it is no longer used.

impl Deref for QImageIOPlugin[src]

type Target = QObject

The resulting type after dereferencing.

fn deref(&self) -> &QObject[src]

Calls C++ function: QObject* static_cast<QObject*>(QImageIOPlugin* ptr).

impl DynamicCast<QImageIOPlugin> for QObject[src]

unsafe fn dynamic_cast(ptr: Ptr<QObject>) -> Ptr<QImageIOPlugin>[src]

Calls C++ function: QImageIOPlugin* dynamic_cast<QImageIOPlugin*>(QObject* ptr).

impl StaticDowncast<QImageIOPlugin> for QObject[src]

unsafe fn static_downcast(ptr: Ptr<QObject>) -> Ptr<QImageIOPlugin>[src]

Calls C++ function: QImageIOPlugin* static_cast<QImageIOPlugin*>(QObject* ptr).

impl StaticUpcast<QObject> for QImageIOPlugin[src]

unsafe fn static_upcast(ptr: Ptr<QImageIOPlugin>) -> Ptr<QObject>[src]

Calls C++ function: QObject* static_cast<QObject*>(QImageIOPlugin* ptr).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.