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 图像阅读器支持的任何格式提供,因此 SVG 图形可以与 PNG、TIFF 和其他位图格式一起包含。

另请参阅 QImageQImageReader

成员函数文档

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)

设置图片的namename 用于在应用程序资源中定位图片。

另请参阅 name()。

void QTextImageFormat::setQuality(int quality = 100)

设置导出图像时导出程序应使用的质量。当导出到 ODF 文件时,如果quality 设置为 0 到 100 之间的值,QTextDocumentWriter 将以此处设置的quality 导出 jpg 图像。或者,如果quality 设置为 100(默认值)或更大,它将导出 png 图像。

另请参阅 quality() 。

void QTextImageFormat::setWidth(qreal width)

设置图像所占矩形的width

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

qreal QTextImageFormat::width() const

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

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

© 2025 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.