本页内容

QTextImageFormat Class

QTextImageFormat 类为QTextDocument 中的图像提供格式化信息。更多内容...

头文件: #include <QTextImageFormat>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
继承自: QTextCharFormat

注意:该类中的所有函数均为可重入的。

公共函数

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

详细说明

内联图像由 Unicode 值 U+FFFC(对象替换字符)表示,该值与 QTextImageFormat 相关联。图像格式通过setName() 指定一个名称,该名称用于定位图像。 图像所占矩形的大小使用setWidth() 和setHeight() 以像素为单位指定。可以通过setQuality() 设置所需的图像质量。

图像可以是 Qt 支持的任何格式,因此除了 PNG、TIFF 和其他位图格式外,还可以包含 SVG 绘图。

另请参阅 QImage 和QImageReader 。

成员函数文档

QTextImageFormat::QTextImageFormat()

创建一个新的图像格式对象。

qreal QTextImageFormat::height() const

返回图像所占矩形的高。

另请参阅 width() 和setHeight()。

bool QTextImageFormat::isValid() const

如果该图像格式有效,则返回true ;否则返回false 。

QTextLength QTextImageFormat::maximumWidth() const

返回图像所占矩形的最大宽度。

另请参阅 width() 和setMaximumWidth()。

QString QTextImageFormat::name() const

返回图像的名称。该名称指的是应用程序资源文件中的一个条目。

另请参阅 setName()。

int QTextImageFormat::quality() const

返回由 `setQuality()` 设置的值。

另请参阅 setQuality()。

void QTextImageFormat::setHeight(qreal height)

设置图像所占矩形的height 值。

另请参阅 height() 和setWidth()。

void QTextImageFormat::setMaximumWidth(QTextLength maximumWidth)

设置图像所占矩形的maximumWidth 。该值可以是绝对数值,也可以是可用文档大小的百分比。

另请参阅 maximumWidth()、width() 和setHeight()。

void QTextImageFormat::setName(const QString &name)

设置图像的name 。name 用于在应用程序的资源中定位该图像。

另请参阅 name()。

void QTextImageFormat::setQuality(int quality = 100)

设置导出器在导出图像时应使用的质量。当 `quality ` 的值在 0 到 100 之间时,QTextDocumentWriter 在将图像导出到 ODF 文件时,会使用此处设置的 `quality ` 值导出 JPG 图像;或者,当 `quality ` 设置为 100(默认值)或更高时,则会导出 PNG 图像。

另请参阅 quality()。

void QTextImageFormat::setWidth(qreal width)

设置图像所占矩形的width 。

另请参阅 width()、setHeight() 和maximumWidth()。

qreal QTextImageFormat::width() const

返回图像所占矩形的宽度。

另请参阅 height() 和setWidth()。

© 2026 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 the GNU 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.