![]() |
Qt 6.x
The Qt SDK
|
#include <qquicktextdocument_p.h>
Public Slots | |
void | clearResources () |
![]() | |
void | undo () |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | redo () |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Redoes the last editing operation on the document if \l{QTextDocument::isRedoAvailable()}{redo is available}. | |
void | appendUndoItem (QAbstractUndoItem *) |
void | setModified (bool m=true) |
![]() | |
void | deleteLater () |
\threadsafe | |
Signals | |
void | imagesLoaded () |
![]() | |
void | contentsChange (int from, int charsRemoved, int charsAdded) |
This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied. | |
void | contentsChanged () |
This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied. | |
void | undoAvailable (bool) |
This signal is emitted whenever undo operations become available (available is true) or unavailable (available is false). | |
void | redoAvailable (bool) |
This signal is emitted whenever redo operations become available (available is true) or unavailable (available is false). | |
void | undoCommandAdded () |
void | modificationChanged (bool m) |
This signal is emitted whenever the content of the document changes in a way that affects the modification state. | |
void | cursorPositionChanged (const QTextCursor &cursor) |
This signal is emitted whenever the position of a cursor changed due to an editing operation. | |
void | blockCountChanged (int newBlockCount) |
void | baseUrlChanged (const QUrl &url) |
void | documentLayoutChanged () |
![]() | |
void | destroyed (QObject *=nullptr) |
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked. | |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
This signal is emitted after the object's name has been changed. | |
Public Member Functions | |
QQuickTextDocumentWithImageResources (QQuickItem *parent) | |
virtual | ~QQuickTextDocumentWithImageResources () |
int | resourcesLoading () const |
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 document (doc) at the given position (posInDocument). | |
void | drawObject (QPainter *p, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) override |
Draws this text object using the specified painter. | |
QImage | image (const QTextImageFormat &format) const |
![]() | |
QTextDocument (QObject *parent=nullptr) | |
Constructs an empty QTextDocument with the given parent. | |
QTextDocument (const QString &text, QObject *parent=nullptr) | |
Constructs a QTextDocument containing the plain (unformatted) text specified, and with the given parent. | |
~QTextDocument () | |
Destroys the document. | |
QTextDocument * | clone (QObject *parent=nullptr) const |
Creates a new QTextDocument that is a copy of this text document. | |
bool | isEmpty () const |
Returns true if the document is empty; otherwise returns false . | |
virtual void | clear () |
Clears the document. | |
void | setUndoRedoEnabled (bool enable) |
bool | isUndoRedoEnabled () const |
bool | isUndoAvailable () const |
Returns true if undo is available; otherwise returns false . | |
bool | isRedoAvailable () const |
Returns true if redo is available; otherwise returns false . | |
int | availableUndoSteps () const |
int | availableRedoSteps () const |
int | revision () const |
void | setDocumentLayout (QAbstractTextDocumentLayout *layout) |
Sets the document to use the given layout. | |
QAbstractTextDocumentLayout * | documentLayout () const |
Returns the document layout for this document. | |
void | setMetaInformation (MetaInformation info, const QString &) |
Sets the document's meta information of the type specified by info to the given string. | |
QString | metaInformation (MetaInformation info) const |
Returns meta information about the document of the type specified by info. | |
QString | toHtml () const |
Returns a string containing an HTML representation of the document. | |
void | setHtml (const QString &html) |
Replaces the entire contents of the document with the given HTML-formatted text in the html string. | |
QString | toRawText () const |
Returns the raw text contained in the document without any formatting information. | |
QString | toPlainText () const |
Returns the plain text contained in the document. | |
void | setPlainText (const QString &text) |
Replaces the entire contents of the document with the given plain text. | |
QChar | characterAt (int pos) const |
QTextCursor | find (const QString &subString, int from=0, FindFlags options=FindFlags()) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Finds the next occurrence of the string, subString, in the document. | |
QTextCursor | find (const QString &subString, const QTextCursor &cursor, FindFlags options=FindFlags()) const |
Finds the next occurrence of the string, subString, in the document. | |
QTextFrame * | frameAt (int pos) const |
QTextFrame * | rootFrame () const |
Returns the document's root frame. | |
QTextObject * | object (int objectIndex) const |
Returns the text object associated with the given objectIndex. | |
QTextObject * | objectForFormat (const QTextFormat &) const |
Returns the text object associated with the format f. | |
QTextBlock | findBlock (int pos) const |
Returns the text block that contains the {pos}-th character. | |
QTextBlock | findBlockByNumber (int blockNumber) const |
QTextBlock | findBlockByLineNumber (int blockNumber) const |
QTextBlock | begin () const |
Returns the document's first text block. | |
QTextBlock | end () const |
This function returns a block to test for the end of the document while iterating over it. | |
QTextBlock | firstBlock () const |
QTextBlock | lastBlock () const |
void | setPageSize (const QSizeF &size) |
QSizeF | pageSize () const |
void | setDefaultFont (const QFont &font) |
Sets the default font to use in the document layout. | |
QFont | defaultFont () const |
Returns the default font to be used in the document layout. | |
void | setSuperScriptBaseline (qreal baseline) |
qreal | superScriptBaseline () const |
void | setSubScriptBaseline (qreal baseline) |
qreal | subScriptBaseline () const |
void | setBaselineOffset (qreal baseline) |
qreal | baselineOffset () const |
int | pageCount () const |
returns the number of pages in this document. | |
bool | isModified () const |
void | print (QPagedPaintDevice *printer) const |
Prints the document to the given printer. | |
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. | |
QTextDocument::ResourceProvider | resourceProvider () const |
void | setResourceProvider (const ResourceProvider &provider) |
QList< QTextFormat > | allFormats () const |
Returns a list of text formats for all the formats used in the document. | |
void | markContentsDirty (int from, int length) |
Marks the contents specified by the given position and length as "dirty", informing the document that it needs to be laid out again. | |
void | setUseDesignMetrics (bool b) |
bool | useDesignMetrics () const |
void | setLayoutEnabled (bool b) |
bool | isLayoutEnabled () const |
void | drawContents (QPainter *painter, const QRectF &rect=QRectF()) |
void | setTextWidth (qreal width) |
qreal | textWidth () const |
qreal | idealWidth () const |
qreal | indentWidth () const |
void | setIndentWidth (qreal width) |
qreal | documentMargin () const |
void | setDocumentMargin (qreal margin) |
void | adjustSize () |
QSizeF | size () const |
int | blockCount () const |
int | lineCount () const |
int | characterCount () const |
void | setDefaultStyleSheet (const QString &sheet) |
QString | defaultStyleSheet () const |
void | undo (QTextCursor *cursor) |
void | redo (QTextCursor *cursor) |
void | clearUndoRedoStacks (Stacks historyToClear=UndoAndRedoStacks) |
int | maximumBlockCount () const |
void | setMaximumBlockCount (int maximum) |
QTextOption | defaultTextOption () const |
the default text option will be set on all \l{QTextLayout}s in the document. | |
void | setDefaultTextOption (const QTextOption &option) |
QUrl | baseUrl () const |
void | setBaseUrl (const QUrl &url) |
Qt::CursorMoveStyle | defaultCursorMoveStyle () const |
void | setDefaultCursorMoveStyle (Qt::CursorMoveStyle style) |
![]() | |
Q_INVOKABLE | QObject (QObject *parent=nullptr) |
Constructs an object with parent object parent. | |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. | |
virtual bool | event (QEvent *event) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. | |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
Filters events if this object has been installed as an event filter for the watched object. | |
QString | objectName () const |
Q_WEAK_OVERLOAD void | setObjectName (const QString &name) |
Sets the object's name to name. | |
void | setObjectName (QAnyStringView name) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QBindable< QString > | bindableObjectName () |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false . | |
bool | isWindowType () const |
Returns true if the object is a window; otherwise returns false . | |
bool | isQuickItemType () const |
Returns true if the object is a QQuickItem; otherwise returns false . | |
bool | signalsBlocked () const noexcept |
Returns true if signals are blocked; otherwise returns false . | |
bool | blockSignals (bool b) noexcept |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). | |
QThread * | thread () const |
Returns the thread in which the object lives. | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. | |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds. | |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
void | killTimer (int id) |
Kills the timer with timer identifier, id. | |
template<typename T > | |
T | findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. | |
template<typename T > | |
QList< T > | findChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. | |
template<typename T > | |
QList< T > | findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
const QObjectList & | children () const |
Returns a list of child objects. | |
void | setParent (QObject *parent) |
Makes the object a child of parent. | |
void | installEventFilter (QObject *filterObj) |
Installs an event filter filterObj on this object. | |
void | removeEventFilter (QObject *obj) |
Removes an event filter object obj from this object. | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const |
bool | disconnect (const QObject *receiver, const char *member=nullptr) const |
void | dumpObjectTree () const |
Dumps a tree of children to the debug output. | |
void | dumpObjectInfo () const |
Dumps information about signal connections, etc. | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. | |
bool | setProperty (const char *name, QVariant &&value) |
QVariant | property (const char *name) const |
Returns the value of the object's name property. | |
QList< QByteArray > | dynamicPropertyNames () const |
QBindingStorage * | bindingStorage () |
const QBindingStorage * | bindingStorage () const |
QObject * | parent () const |
Returns a pointer to the parent object. | |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false . | |
![]() | |
virtual | ~QTextObjectInterface () |
Destroys this QTextObjectInterface. | |
virtual QSizeF | intrinsicSize (QTextDocument *doc, int posInDocument, const QTextFormat &format)=0 |
The intrinsicSize() function returns the size of the text object represented by format in the given document (doc) at the given position (posInDocument). | |
virtual void | drawObject (QPainter *painter, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format)=0 |
Draws this text object using the specified painter. | |
Protected Member Functions | |
QVariant | loadResource (int type, const QUrl &name) override |
Loads data of the specified type from the resource with the given name. | |
QQuickPixmap * | loadPixmap (QQmlContext *context, const QUrl &name) |
![]() | |
virtual QTextObject * | createObject (const QTextFormat &f) |
Creates and returns a new document object (a QTextObject), based on the given format. | |
virtual Q_INVOKABLE QVariant | loadResource (int type, const QUrl &name) |
Loads data of the specified type from the resource with the given name. | |
QTextDocument (QTextDocumentPrivate &dd, QObject *parent) | |
![]() | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. | |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. | |
bool | isSignalConnected (const QMetaMethod &signal) const |
virtual void | timerEvent (QTimerEvent *event) |
This event handler can be reimplemented in a subclass to receive timer events for the object. | |
virtual void | childEvent (QChildEvent *event) |
This event handler can be reimplemented in a subclass to receive child events. | |
virtual void | customEvent (QEvent *event) |
This event handler can be reimplemented in a subclass to receive custom events. | |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
QObject (QObjectPrivate &dd, QObject *parent=nullptr) | |
Additional Inherited Members | |
![]() | |
enum | MetaInformation { DocumentTitle , DocumentUrl , CssMedia } |
This enum describes the different types of meta information that can be added to a document. More... | |
enum | FindFlag { FindBackward = 0x00001 , FindCaseSensitively = 0x00002 , FindWholeWords = 0x00004 } |
This enum describes the options available to QTextDocument's find function. More... | |
enum | ResourceType { UnknownResource = 0 , HtmlResource = 1 , ImageResource = 2 , StyleSheetResource = 3 , MarkdownResource = 4 , UserResource = 100 } |
This enum describes the types of resources that can be loaded by QTextDocument's loadResource() function or by QTextBrowser::setSource(). More... | |
enum | Stacks { UndoStack = 0x01 , RedoStack = 0x02 , UndoAndRedoStacks = UndoStack | RedoStack } |
\value UndoStack The undo stack. More... | |
using | ResourceProvider = std::function< QVariant(const QUrl &)> |
![]() | |
static QTextDocument::ResourceProvider | defaultResourceProvider () |
static void | setDefaultResourceProvider (const ResourceProvider &provider) |
![]() | |
static QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
\threadsafe | |
static QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
\threadsafe | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static bool | disconnect (const QMetaObject::Connection &) |
Disconnect a connection. | |
template<typename Func1 , typename Func2 > | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot) |
template<typename Func1 > | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero) |
![]() | |
QScopedPointer< QObjectData > | d_ptr |
![]() | |
bool | undoRedoEnabled |
whether undo/redo are enabled for this document | |
bool | modified |
whether the document has been modified by the user | |
QSizeF | pageSize |
the page size that should be used for laying out the document | |
QFont | defaultFont |
the default font used to display the document's text | |
bool | useDesignMetrics |
whether the document uses design metrics of fonts to improve the accuracy of text layout | |
bool | layoutEnabled |
whether QTextDocument should recalculate the layout after every change | |
QSizeF | size |
the actual size of the document. This is equivalent to documentLayout()->documentSize(); | |
qreal | textWidth |
int | blockCount |
the number of text blocks in the document. | |
qreal | indentWidth |
QString | defaultStyleSheet |
int | maximumBlockCount |
Specifies the limit for blocks in the document. | |
qreal | documentMargin |
QUrl | baseUrl |
the base URL used to resolve relative resource URLs within the document. | |
![]() | |
QString | objectName |
the name of this object | |
![]() | |
template< class T > T | qobject_cast (const QObject *object) |
Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. | |
template< typename T > T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
template< typename T > QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QObjectList | |
\macro Q_CLASSINFO(Name, Value) | |
Definition at line 32 of file qquicktextdocument_p.h.
QQuickTextDocumentWithImageResources::QQuickTextDocumentWithImageResources | ( | QQuickItem * | parent | ) |
Definition at line 63 of file qquicktextdocument.cpp.
References QTextDocument::baseUrlChanged(), QTextDocument::characterCount(), clearResources(), QObject::connect(), QTextDocument::documentLayout(), QTextFormat::ImageObject, QTextDocument::markContentsDirty(), QAbstractTextDocumentLayout::registerHandler(), and QTextDocument::setUndoRedoEnabled().
|
virtual |
Definition at line 74 of file qquicktextdocument.cpp.
References QHash< Key, T >::isEmpty(), and qDeleteAll().
|
slot |
Definition at line 181 of file qquicktextdocument.cpp.
References QHash< Key, T >::clear(), pixmap, and qDeleteAll().
Referenced by QQuickTextDocumentWithImageResources().
|
overridevirtual |
Draws this text object using the specified painter.
The size of the rectangle, rect, to draw in is the size previously calculated by intrinsicSize(). The rectangles position is relative to the painter.
You also get the document (doc) and the position (posInDocument) of the format in that document.
Implements QTextObjectInterface.
Definition at line 144 of file qquicktextdocument.cpp.
QImage QQuickTextDocumentWithImageResources::image | ( | const QTextImageFormat & | format | ) | const |
Definition at line 149 of file qquicktextdocument.cpp.
References QTextDocument::ImageResource, and QTextDocument::resource().
|
signal |
|
overridevirtual |
The intrinsicSize() function returns the size of the text object represented by format in the given document (doc) at the given position (posInDocument).
The size calculated will be used for subsequent calls to drawObject() for this format.
Implements QTextObjectInterface.
Definition at line 102 of file qquicktextdocument.cpp.
References QTextFormat::hasProperty(), QTextImageFormat::height(), QSize::height(), QTextFormat::ImageHeight, QTextDocument::ImageResource, QTextFormat::ImageWidth, QTextImageFormat::name(), qRound(), QTextDocument::resource(), QTextDocument::size, QTextFormat::toImageFormat(), QTextImageFormat::width(), and QSize::width().
|
protected |
Definition at line 155 of file qquicktextdocument.cpp.
References QSet< T >::contains(), context, QHash< Key, T >::end(), QHash< Key, T >::find(), QHash< Key, T >::insert(), QSet< T >::insert(), iter, QObject::parent(), qmlWarning(), SLOT, and url.
Referenced by loadResource().
|
overrideprotectedvirtual |
Loads data of the specified type from the resource with the given name.
This function is called by the rich text engine to request data that isn't directly stored by QTextDocument, but still associated with it. For example, images are referenced indirectly by the name attribute of a QTextImageFormat object.
When called by Qt, type is one of the values of QTextDocument::ResourceType.
If the QTextDocument is a child object of a QObject that has an invokable loadResource method such as QTextEdit, QTextBrowser or a QTextDocument itself then the default implementation tries to retrieve the data from the parent.
Reimplemented from QTextDocument.
Definition at line 80 of file qquicktextdocument.cpp.
References QTextDocument::baseUrl, context, QTextDocument::ImageResource, QVariant::isNull(), loadPixmap(), QTextDocument::loadResource(), QObject::parent(), qmlContext(), QUrl::resolved(), QTextDocument::resource(), and url.
|
inline |
Definition at line 40 of file qquicktextdocument_p.h.