- Qt 5.15
- Qt GUI
- C++ Classes
- QTextImageFormat
- Qt 5.15.18 Reference Documentation

# QTextImageFormat Class

The QTextImageFormat class provides formatting information for images in a QTextDocument. More...

Header: | #include <QTextImageFormat>
qmake: | QT += gui
Inherits: | QTextCharFormat

- List of all members, including inherited members

Note: All functions in this class are reentrant.

## Public Functions

| QTextImageFormat()
qreal | height() const
bool | isValid() const
QString | name() const
int | quality() const
void | setHeight(qreal height)
void | setName(const QString &name)
void | setQuality(int quality = 100)
void | setWidth(qreal width)
qreal | width() const

## Detailed Description

Inline images are represented by a Unicode value U+FFFC (OBJECT REPLACEMENT CHARACTER) which has an associated QTextImageFormat. The image format specifies a name with setName() that is used to locate the image. The size of the rectangle that the image will occupy is specified in pixels using setWidth() and setHeight(). The desired image quality may be set with setQuality().

Images can be supplied in any format for which Qt has an image reader, so SVG drawings can be included alongside PNG, TIFF and other bitmap formats.

See also QImage and QImageReader.

## Member Function Documentation

### QTextImageFormat::QTextImageFormat()

Creates a new image format object.

### qreal QTextImageFormat::height() const

Returns the height of the rectangle occupied by the image.

See also width() and setHeight().

### bool QTextImageFormat::isValid() const

Returns `true` if this image format is valid; otherwise returns `false`.

### QString QTextImageFormat::name() const

Returns the name of the image. The name refers to an entry in the application's resources file.

See also setName().

### int QTextImageFormat::quality() const

Returns the value set by setQuality().

This function was introduced in Qt 5.12.

See also setQuality().

### void QTextImageFormat::setHeight(qreal height)

Sets the height of the rectangle occupied by the image.

See also height() and setWidth().

### void QTextImageFormat::setName(const QString &name)

Sets the name of the image. The name is used to locate the image in the application's resources.

See also name().

### void QTextImageFormat::setQuality(int quality = 100)

Sets the quality that should be used by exporters when exporting the image. QTextDocumentWriter will export jpg images with the quality set here when exporting to ODF files if quality is set to a value between 0 and 100. Or it will export png images if quality is set to 100 (default) or greater.

This function was introduced in Qt 5.12.

See also quality().

### void QTextImageFormat::setWidth(qreal width)

Sets the width of the rectangle occupied by the image.

See also width() and setHeight().

### qreal QTextImageFormat::width() const

Returns the width of the rectangle occupied by the image.

See also height() and setWidth().