12#include <private/qtextengine_p.h>
22 qreal targetDevicePixelRatio,
23 qreal *sourceDevicePixelRatio)
31 else if (baseFileName.startsWith(
"qrc:/"_L1))
32 localFile = baseFileName.
sliced(3);
34 localFile = baseFileName;
36 qreal *sourceDevicePixelRatio);
37 return qt_findAtNxFile(localFile, targetDevicePixelRatio, sourceDevicePixelRatio);
42 if (
path.startsWith(
":/"_L1))
50 qreal sourcePixelRatio = 1.0;
56 if (
data.userType() == QMetaType::QPixmap ||
data.userType() == QMetaType::QImage)
58 else if (
data.metaType() == QMetaType::fromType<QByteArray>())
63 return T(
":/qt-project.org/styles/commonstyle/images/file-16.png"_L1);
67 if (sourcePixelRatio != 1.0)
68 result.setDevicePixelRatio(sourcePixelRatio);
81 const auto maxWidth =
format.maximumWidth();
83 int effectiveMaxWidth = std::numeric_limits<int>::max();
88 effectiveMaxWidth = maxWidth.rawValue();
95 if (!hasWidth || !hasHeight) {
99 if (sourceSize.
width() > effectiveMaxWidth) {
102 sourceSize.
setWidth(effectiveMaxWidth);
142 return getSize<QImage>(doc, imageFormat);
143 return getSize<QPixmap>(doc, imageFormat);
150 return getAs<QImage>(doc, imageFormat);
159 const QImage image = getAs<QImage>(doc, imageFormat,
p->device()->devicePixelRatio());
162 const QPixmap pixmap = getAs<QPixmap>(doc, imageFormat,
p->device()->devicePixelRatio());
169#include "moc_qtextimagehandler_p.cpp"
QPaintDevice * paintDevice() const
Returns the paint device used to render the document's layout.
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
QThread * thread() const
Returns the thread in which the object lives.
The QPainter class performs low-level painting on widgets and other paint devices.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
\inmodule QtCore\reentrant
constexpr void setHeight(qreal h) noexcept
Sets the height to the given finite height.
constexpr void setWidth(qreal w) noexcept
Sets the width to the given finite width.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString sliced(qsizetype pos) const &
\reentrant \inmodule QtGui
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QSizeF pageSize
the page size that should be used for laying out the document
QVariant resource(int type, const QUrl &name) const
Returns data of the specified type from the resource with the given name.
void addResource(int type, const QUrl &name, const QVariant &resource)
Adds the resource resource to the resource cache, using type and name as identifiers.
QTextImageFormat toImageFormat() const
Returns this format as an image format.
virtual void drawObject(QPainter *p, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) override
Draws this text object using the specified painter.
virtual QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format) override
The intrinsicSize() function returns the size of the text object represented by format in the given d...
QTextImageHandler(QObject *parent=nullptr)
QImage image(QTextDocument *doc, const QTextImageFormat &imageFormat)
static QThread * currentThread()
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Combined button and popup list for selecting options.
int qRound(qfloat16 d) noexcept
Q_GUI_EXPORT int qt_defaultDpi()
QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio, qreal *sourceDevicePixelRatio)
constexpr const T & qMin(const T &a, const T &b)
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
GLsizei const GLchar *const * path
GLenum GLenum GLenum GLenum GLenum scale
static QSize getSize(QTextDocument *doc, const QTextImageFormat &format)
static QUrl fromLocalfileOrResources(QString path)
static T getAs(QTextDocument *doc, const QTextImageFormat &format, const qreal devicePixelRatio=1.0)
static QString findAtNxFileOrResource(const QString &baseFileName, qreal targetDevicePixelRatio, qreal *sourceDevicePixelRatio)
QUrl url("example.com")
[constructor-url-reference]