QTextFormat Class

Die Klasse QTextFormat liefert Formatierungsinformationen für eine QTextDocument. Mehr...

Kopfzeile: #include <QTextFormat>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
Vererbt von:

QTextBlockFormat, QTextCharFormat, QTextFrameFormat, und QTextListFormat

Hinweis: Alle Funktionen in dieser Klasse sind reentrant.

Öffentliche Typen

enum FormatType { InvalidFormat, BlockFormat, CharFormat, ListFormat, FrameFormat, UserFormat }
enum ObjectTypes { NoObject, ImageObject, TableObject, TableCellObject, UserObject }
enum PageBreakFlag { PageBreak_Auto, PageBreak_AlwaysBefore, PageBreak_AlwaysAfter }
flags PageBreakFlags
enum Property { ObjectIndex, CssFloat, LayoutDirection, OutlinePen, ForegroundBrush, …, UserProperty }

Öffentliche Funktionen

QTextFormat()
QTextFormat(int type)
QTextFormat(const QTextFormat &other)
~QTextFormat()
QBrush background() const
bool boolProperty(int propertyId) const
QBrush brushProperty(int propertyId) const
void clearBackground()
void clearForeground()
void clearProperty(int propertyId)
QColor colorProperty(int propertyId) const
qreal doubleProperty(int propertyId) const
QBrush foreground() const
bool hasProperty(int propertyId) const
int intProperty(int propertyId) const
bool isBlockFormat() const
bool isCharFormat() const
bool isEmpty() const
bool isFrameFormat() const
bool isImageFormat() const
bool isListFormat() const
bool isTableCellFormat() const
bool isTableFormat() const
bool isValid() const
Qt::LayoutDirection layoutDirection() const
QTextLength lengthProperty(int propertyId) const
QList<QTextLength> lengthVectorProperty(int propertyId) const
void merge(const QTextFormat &other)
int objectIndex() const
int objectType() const
QPen penProperty(int propertyId) const
QMap<int, QVariant> properties() const
QVariant property(int propertyId) const
int propertyCount() const
void setBackground(const QBrush &brush)
void setForeground(const QBrush &brush)
void setLayoutDirection(Qt::LayoutDirection direction)
void setObjectIndex(int index)
void setObjectType(int type)
void setProperty(int propertyId, const QList<QTextLength> &value)
void setProperty(int propertyId, const QVariant &value)
QString stringProperty(int propertyId) const
void swap(QTextFormat &other)
QTextBlockFormat toBlockFormat() const
QTextCharFormat toCharFormat() const
QTextFrameFormat toFrameFormat() const
QTextImageFormat toImageFormat() const
QTextListFormat toListFormat() const
QTextTableCellFormat toTableCellFormat() const
QTextTableFormat toTableFormat() const
int type() const
QVariant operator QVariant() const
bool operator!=(const QTextFormat &other) const
QTextFormat &operator=(const QTextFormat &other)
bool operator==(const QTextFormat &other) const

Detaillierte Beschreibung

Ein QTextFormat ist eine generische Klasse zur Beschreibung des Formats von Teilen eines QTextDocument. Die abgeleiteten Klassen QTextCharFormat, QTextBlockFormat, QTextListFormat und QTextTableFormat sind in der Regel nützlicher und beschreiben die Formatierung, die auf bestimmte Teile des Dokuments angewendet wird.

Ein Format hat eine FormatType, die die Arten von Textelementen angibt, die es formatieren kann, z. B. einen Textblock, eine Liste, eine Tabelle usw. Ein Format hat auch verschiedene Eigenschaften (einige spezifisch für bestimmte Formattypen), die durch das Property-Enum beschrieben werden. Jede Eigenschaft hat eine entsprechende Property.

Der Formattyp wird durch type() angegeben, und das Format kann mit isCharFormat(), isBlockFormat(), isListFormat(), isTableFormat(), isFrameFormat() und isImageFormat() getestet werden. Wenn der Typ bestimmt ist, kann er mit toCharFormat(), toBlockFormat(), toListFormat(), toTableFormat(), toFrameFormat() und toImageFormat() abgerufen werden.

Die Eigenschaften eines Formats können mit den Funktionen setProperty() festgelegt und gegebenenfalls mit boolProperty(), intProperty(), doubleProperty() und stringProperty() abgerufen werden. Alle im Format verwendeten Eigenschafts-IDs können mit allPropertyIds() abgerufen werden. Ein Format kann mit merge() in ein anderes zusammengeführt werden.

Der Objektindex eines Formats kann mit setObjectIndex() gesetzt und mit objectIndex() abgerufen werden. Diese Methoden können verwendet werden, um das Format mit einem QTextObject zu verknüpfen. Es wird verwendet, um Listen, Rahmen und Tabellen innerhalb des Dokuments darzustellen.

Siehe auch Rich Text Processing.

Dokumentation der Mitgliedstypen

enum QTextFormat::FormatType

Diese Aufzählung beschreibt das Textelement, das ein QTextFormat Objekt formatiert.

KonstanteWertBeschreibung
QTextFormat::InvalidFormat-1Ein ungültiges Format, wie es vom Standardkonstruktor erzeugt wird
QTextFormat::BlockFormat1Das Objekt formatiert einen Textblock
QTextFormat::CharFormat2Das Objekt formatiert ein einzelnes Zeichen
QTextFormat::ListFormat3Das Objekt formatiert eine Liste
QTextFormat::FrameFormat5Das Objekt formatiert einen Rahmen
QTextFormat::UserFormat100

Siehe auch QTextCharFormat, QTextBlockFormat, QTextListFormat, QTextTableFormat, und type().

enum QTextFormat::ObjectTypes

Diese Aufzählung beschreibt, mit welcher Art von QTextObject dieses Format verbunden ist.

KonstanteWertBeschreibung
QTextFormat::NoObject0
QTextFormat::ImageObject1
QTextFormat::TableObject2
QTextFormat::TableCellObject3
QTextFormat::UserObject0x1000Das erste Objekt, das für anwendungsspezifische Zwecke verwendet werden kann.

Siehe auch QTextObject, QTextTable, und QTextObject::format().

enum QTextFormat::PageBreakFlag
flags QTextFormat::PageBreakFlags

Diese Aufzählung beschreibt, wie der Seitenumbruch beim Drucken durchgeführt wird. Sie entspricht den entsprechenden css-Eigenschaften.

KonstanteWertBeschreibung
QTextFormat::PageBreak_Auto0Der Seitenumbruch wird automatisch in Abhängigkeit vom verfügbaren Platz auf der aktuellen Seite bestimmt
QTextFormat::PageBreak_AlwaysBefore0x001Die Seite wird immer vor dem Absatz/der Tabelle umgebrochen
QTextFormat::PageBreak_AlwaysAfter0x010Eine neue Seite wird immer nach dem Absatz/der Tabelle begonnen

Der Typ PageBreakFlags ist ein Typedef für QFlags<PageBreakFlag>. Er speichert eine ODER-Kombination von PageBreakFlag-Werten.

Siehe auch QTextBlockFormat::pageBreakPolicy(), QTextFrameFormat::pageBreakPolicy(), und PageBreakPolicy.

enum QTextFormat::Property

Diese Aufzählung beschreibt die verschiedenen Eigenschaften, die ein Format haben kann.

KonstanteWertBeschreibung
QTextFormat::ObjectIndex0x0Der Index des formatierten Objekts. Siehe objectIndex().

Absatz- und Zeicheneigenschaften

KonstanteWertBeschreibung
QTextFormat::CssFloat0x0800Wie ein Rahmen relativ zum umgebenden Text angeordnet ist
QTextFormat::LayoutDirection0x0801Die Layout-Richtung des Textes im Dokument (Qt::LayoutDirection).
QTextFormat::OutlinePen0x810
QTextFormat::ForegroundBrush0x821
QTextFormat::BackgroundBrush0x820
QTextFormat::BackgroundImageUrl0x823

Absatz-Eigenschaften

KonstanteWertBeschreibung
QTextFormat::BlockAlignment0x1010
QTextFormat::BlockTopMargin0x1030
QTextFormat::BlockBottomMargin0x1031
QTextFormat::BlockLeftMargin0x1032
QTextFormat::BlockRightMargin0x1033
QTextFormat::TextIndent0x1034
QTextFormat::TabPositions0x1035Gibt die Tabulatorpositionen an. Die Tabulatorpositionen sind Structs von QTextOption::Tab, die in einem QList (intern in einem QList<QVariant>) gespeichert werden.
QTextFormat::BlockIndent0x1040
QTextFormat::LineHeight0x1048
QTextFormat::LineHeightType0x1049
QTextFormat::BlockNonBreakableLines0x1050
QTextFormat::BlockTrailingHorizontalRulerWidth0x1060Die Breite eines horizontalen Linealelements.
QTextFormat::HeadingLevel0x1070Die Ebene einer Überschrift, z.B. 1 entspricht einem HTML H1-Tag, sonst 0. Dieser Enum-Wert wurde in Qt 5.12 hinzugefügt.
QTextFormat::BlockCodeFence0x1091Das Zeichen, das in den "Zäunen" um einen Markdown-Codeblock verwendet wurde. Wenn der Codeblock eingerückt und nicht umrahmt wurde, sollte der Block diese Eigenschaft nicht haben. Dieser Enum-Wert wurde in Qt 5.14 hinzugefügt.
QTextFormat::BlockQuoteLevel0x1080Die Tiefe der verschachtelten Anführungszeichen in diesem Block: 1 bedeutet, dass der Block ein Block-Zeichen der obersten Ebene ist. Blöcke, die keine Blockquotierungen sind, sollten diese Eigenschaft nicht haben. Dieser Enum-Wert wurde in Qt 5.14 hinzugefügt.
QTextFormat::BlockCodeLanguage0x1090Die Programmiersprache in einem vorformatierten oder Code-Block. Blöcke, die keinen Code enthalten, sollten diese Eigenschaft nicht haben. Dieser Enum-Wert wurde in Qt 5.14 hinzugefügt.
QTextFormat::BlockMarker0x10A0Die type of adornment, die neben dem Block angezeigt wird. Dieser Enum-Wert wurde in Qt 5.14 hinzugefügt.

Zeichen-Eigenschaften

KonstanteWertBeschreibung
QTextFormat::FontFamily0x2000e{Diese Eigenschaft ist veraltet.} Verwenden Sie stattdessen QTextFormat::FontFamilies.
QTextFormat::FontFamilies0x1FE7
QTextFormat::FontStyleName0x1FE8
QTextFormat::FontPointSize0x2001
QTextFormat::FontPixelSize0x2009
QTextFormat::FontSizeAdjustment0x2002Gibt die Größenänderung der bereits mit FontPointSize oder FontPixelSize eingestellten Schriftgröße an.
QTextFormat::FontFixedPitch0x2008
QTextFormat::FontWeight0x2003
QTextFormat::FontItalic0x2004
QTextFormat::FontUnderline0x2005Diese Eigenschaft ist veraltet. Verwenden Sie stattdessen QTextFormat::TextUnderlineStyle.
QTextFormat::FontOverline0x2006
QTextFormat::FontStrikeOut0x2007
QTextFormat::FontCapitalizationFirstFontPropertyGibt die Art der Großschreibung an, die auf den Text angewendet werden soll.
QTextFormat::FontLetterSpacingType0x1FE9Legt die Bedeutung der Eigenschaft FontLetterSpacing fest. Die Vorgabe ist QFont::PercentageSpacing.
QTextFormat::FontLetterSpacing0x1FE1Ändert den Standardabstand zwischen einzelnen Buchstaben in der Schriftart. Der Wert wird je nach FontLetterSpacingType als Prozentwert oder absoluter Wert angegeben. Der Standardwert ist 100%.
QTextFormat::FontWordSpacing0x1FE2Ändert den Standardabstand zwischen den einzelnen Wörtern. Ein positiver Wert vergrößert den Wortabstand um die entsprechenden Pixel, ein negativer Wert verkleinert den Abstand.
QTextFormat::FontStretch0x1FEAEntspricht der Eigenschaft QFont::Stretch
QTextFormat::FontStyleHint0x1FE3Entspricht der Eigenschaft QFont::StyleHint
QTextFormat::FontStyleStrategy0x1FE4Entspricht der Eigenschaft QFont::StyleStrategy
QTextFormat::FontKerning0x1FE5Gibt an, ob in der Schriftart das Kerning aktiviert ist.
QTextFormat::FontHintingPreference0x1FE6Steuert die Verwendung von Hinting entsprechend den Werten des QFont::HintingPreference enum.
QTextFormat::TextUnderlineColor0x2020Legt die Farbe für Unterstreichungen, Überstreichungen und Durchstreichungen fest.
QTextFormat::TextVerticalAlignment0x2021Legt die Art der vertikalen Ausrichtung des Textes entsprechend den Werten der Aufzählung QTextCharFormat::VerticalAlignment fest.
QTextFormat::TextOutline0x2022Legt eine QPen fest, die zum Zeichnen der Textkontur verwendet wird.
QTextFormat::TextUnderlineStyle0x2023Legt den Stil der Textunterstreichung entsprechend den Werten des QTextCharFormat::UnderlineStyle enum fest.
QTextFormat::TextToolTip0x2024Legt den (optionalen) Tooltip fest, der für ein Textfragment angezeigt werden soll.
QTextFormat::TextSuperScriptBaseline0x2025Legt die Grundlinie (in % der Höhe) von hochgestellten Texten fest.
QTextFormat::TextSubScriptBaseline0x2026Legt die Grundlinie (in % der Höhe) von tiefgestellten Texten fest.
QTextFormat::TextBaselineOffset0x2027Legt die Grundlinie (in % der Höhe) des Textes fest. Ein positiver Wert verschiebt den Text um den entsprechenden Prozentsatz nach oben; ein negativer Wert verschiebt ihn nach unten.
QTextFormat::IsAnchor0x2030
QTextFormat::AnchorHref0x2031
QTextFormat::AnchorName0x2032
QTextFormat::ObjectType0x2f00

Eigenschaften der Liste

KonstanteWertBeschreibung
QTextFormat::ListStyle0x3000Gibt den Stil an, der für die Elemente in einer Liste verwendet wird, beschrieben durch die Werte des QTextListFormat::Style enum.
QTextFormat::ListIndent0x3001Legt den Umfang der Einrückung einer Liste fest.
QTextFormat::ListNumberPrefix0x3002Legt den Text fest, der den Positionsnummern in numerischen Listen vorangestellt wird.
QTextFormat::ListNumberSuffix0x3003Legt den Text fest, der in numerischen Listen an die Positionsnummern angehängt wird.
QTextFormat::ListStart (since Qt 6.6)0x3004Legt den ersten Wert einer Liste fest.

Eigenschaften von Tabellen und Rahmen

KonstanteWertBeschreibung
QTextFormat::FrameBorder0x4000
QTextFormat::FrameBorderBrush0x4009
QTextFormat::FrameBorderStyle0x4010Siehe die Aufzählung BorderStyle.
QTextFormat::FrameBottomMargin0x4006
QTextFormat::FrameHeight0x4004
QTextFormat::FrameLeftMargin0x4007
QTextFormat::FrameMargin0x4001
QTextFormat::FramePadding0x4002
QTextFormat::FrameRightMargin0x4008
QTextFormat::FrameTopMargin0x4005
QTextFormat::FrameWidth0x4003
QTextFormat::TableCellSpacing0x4102
QTextFormat::TableCellPadding0x4103
QTextFormat::TableColumns0x4100
QTextFormat::TableColumnWidthConstraints0x4101
QTextFormat::TableHeaderRowCount0x4104
QTextFormat::TableBorderCollapse0x4105Gibt die Eigenschaft QTextTableFormat::borderCollapse an.

Eigenschaften von Tabellenzellen

KonstanteWert
QTextFormat::TableCellRowSpan0x4810
QTextFormat::TableCellColumnSpan0x4811
QTextFormat::TableCellLeftPadding0x4814
QTextFormat::TableCellRightPadding0x4815
QTextFormat::TableCellTopPadding0x4812
QTextFormat::TableCellBottomPadding0x4813

Eigenschaften von Tabellenzellen, die für die Verwendung bei aktiviertem QTextTableFormat::borderCollapse vorgesehen sind

KonstanteWert
QTextFormat::TableCellTopBorder0x4816
QTextFormat::TableCellBottomBorder0x4817
QTextFormat::TableCellLeftBorder0x4818
QTextFormat::TableCellRightBorder0x4819
QTextFormat::TableCellTopBorderStyle0x481a
QTextFormat::TableCellBottomBorderStyle0x481b
QTextFormat::TableCellLeftBorderStyle0x481c
QTextFormat::TableCellRightBorderStyle0x481d
QTextFormat::TableCellTopBorderBrush0x481e
QTextFormat::TableCellBottomBorderBrush0x481f
QTextFormat::TableCellLeftBorderBrush0x4820
QTextFormat::TableCellRightBorderBrush0x4821

Bild-Eigenschaften

KonstanteWertBeschreibung
QTextFormat::ImageName0x5000Der Dateiname oder die Quelle des Bildes.
QTextFormat::ImageTitle0x5001Das title-Attribut eines HTML-Bild-Tags oder der String in Anführungszeichen, der nach der URL in einem Markdown-Bild-Link steht. Dieser Enum-Wert wurde in Qt 5.14 hinzugefügt.
QTextFormat::ImageAltText0x5002Das alt-Attribut eines HTML-Image-Tags oder die Bildbeschreibung in einem Markdown-Image-Link. Dieser Enum-Wert wurde in Qt 5.14 hinzugefügt.
QTextFormat::ImageWidth0x5010
QTextFormat::ImageHeight0x5011
QTextFormat::ImageQuality0x5014
QTextFormat::ImageMaxWidth0x5015Dieser Enum-Wert wurde in Qt 6.8 hinzugefügt.

Eigenschaften der Auswahl

KonstanteWertBeschreibung
QTextFormat::FullWidthSelection0x06000Wenn dieser Wert auf das characterFormat einer Auswahl gesetzt ist, wird die gesamte Breite des Textes ausgewählt dargestellt.

Seitenumbruch-Eigenschaften

KonstanteWertBeschreibung
QTextFormat::PageBreakPolicy0x7000Legt fest, wie die Seiten umgebrochen werden. Siehe die Aufzählung PageBreakFlag.
QTextFormat::UserProperty0x100000

Siehe auch property() und setProperty().

Dokumentation der Mitgliedsfunktionen

QTextFormat::QTextFormat()

Erzeugt ein neues Textformat mit einem InvalidFormat.

Siehe auch FormatType.

[explicit] QTextFormat::QTextFormat(int type)

Erzeugt ein neues Textformat mit dem angegebenen type.

Siehe auch FormatType.

QTextFormat::QTextFormat(const QTextFormat &other)

Erzeugt ein neues Textformat mit denselben Attributen wie das Textformat other.

[noexcept] QTextFormat::~QTextFormat()

Zerstört dieses Textformat.

QBrush QTextFormat::background() const

Gibt den Pinsel zurück, mit dem der Hintergrund des Dokuments gemalt wurde.

Siehe auch setBackground(), clearBackground(), und foreground().

bool QTextFormat::boolProperty(int propertyId) const

Gibt den Wert der durch propertyId angegebenen Eigenschaft zurück. Wenn die Eigenschaft nicht vom Typ QTextFormat::Bool ist, wird stattdessen false zurückgegeben.

Siehe auch setProperty(), intProperty(), doubleProperty(), stringProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), und Property.

QBrush QTextFormat::brushProperty(int propertyId) const

Gibt den Wert der durch propertyId angegebenen Eigenschaft zurück; wenn die Eigenschaft nicht vom Typ QMetaType::QBrush ist, wird stattdessen Qt::NoBrush zurückgegeben.

Siehe auch setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(), lengthProperty(), lengthVectorProperty(), und Property.

void QTextFormat::clearBackground()

Löscht den Pinsel, mit dem der Hintergrund des Dokuments gemalt wurde. Es wird der Standardpinsel verwendet.

Siehe auch background(), setBackground(), und clearForeground().

void QTextFormat::clearForeground()

Löscht den Pinsel, mit dem der Vordergrund des Dokuments gemalt wird. Es wird der Standardpinsel verwendet.

Siehe auch foreground(), setForeground(), und clearBackground().

void QTextFormat::clearProperty(int propertyId)

Löscht den Wert der Eigenschaft, die durch propertyId

Siehe auch Property.

QColor QTextFormat::colorProperty(int propertyId) const

Gibt den Wert der durch propertyId angegebenen Eigenschaft zurück; wenn die Eigenschaft nicht vom Typ QMetaType::QColor ist, wird stattdessen eine ungültige Farbe zurückgegeben.

Siehe auch setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(), lengthProperty(), lengthVectorProperty(), und Property.

qreal QTextFormat::doubleProperty(int propertyId) const

Gibt den Wert der durch propertyId angegebenen Eigenschaft zurück. Wenn die Eigenschaft nicht vom Typ QMetaType::Double oder QMetaType::Float ist, wird stattdessen 0 zurückgegeben.

Siehe auch setProperty(), boolProperty(), intProperty(), stringProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), und Property.

QBrush QTextFormat::foreground() const

Gibt den Pinsel zurück, der zum Rendern von Details im Vordergrund verwendet wird, wie z. B. Text, Rahmenumrisse und Tabellenränder.

Siehe auch setForeground(), clearForeground(), und background().

bool QTextFormat::hasProperty(int propertyId) const

Gibt true zurück, wenn das Textformat eine Eigenschaft mit der angegebenen propertyId hat; andernfalls wird false zurückgegeben.

Siehe auch properties() und Property.

int QTextFormat::intProperty(int propertyId) const

Gibt den Wert der durch propertyId angegebenen Eigenschaft zurück. Wenn die Eigenschaft nicht vom Typ QTextFormat::Integer ist, wird stattdessen 0 zurückgegeben.

Siehe auch setProperty(), boolProperty(), doubleProperty(), stringProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), und Property.

bool QTextFormat::isBlockFormat() const

Gibt true zurück, wenn dieses Textformat ein BlockFormat ist; andernfalls wird false zurückgegeben.

bool QTextFormat::isCharFormat() const

Gibt true zurück, wenn dieses Textformat ein CharFormat ist; andernfalls wird false zurückgegeben.

bool QTextFormat::isEmpty() const

Gibt true zurück, wenn das Format keine Eigenschaften speichert; andernfalls false.

Siehe auch propertyCount() und properties().

bool QTextFormat::isFrameFormat() const

Gibt true zurück, wenn dieses Textformat ein FrameFormat ist; andernfalls wird false zurückgegeben.

bool QTextFormat::isImageFormat() const

Gibt true zurück, wenn dieses Textformat ein Bildformat ist; andernfalls wird false zurückgegeben.

bool QTextFormat::isListFormat() const

Gibt true zurück, wenn dieses Textformat ein ListFormat ist; andernfalls wird false zurückgegeben.

bool QTextFormat::isTableCellFormat() const

Gibt true zurück, wenn dieses Textformat ein TableCellFormat ist; andernfalls wird false zurückgegeben.

bool QTextFormat::isTableFormat() const

Gibt true zurück, wenn dieses Textformat ein TableFormat ist; andernfalls wird false zurückgegeben.

bool QTextFormat::isValid() const

Gibt true zurück, wenn das Format gültig ist (d.h. nicht InvalidFormat); andernfalls wird false zurückgegeben.

Qt::LayoutDirection QTextFormat::layoutDirection() const

Gibt die Layout-Richtung des Dokuments zurück.

Siehe auch setLayoutDirection().

QTextLength QTextFormat::lengthProperty(int propertyId) const

Gibt den Wert der durch propertyId angegebenen Eigenschaft zurück.

Siehe auch setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(), colorProperty(), lengthVectorProperty(), und Property.

QList<QTextLength> QTextFormat::lengthVectorProperty(int propertyId) const

Gibt den Wert der durch propertyId angegebenen Eigenschaft zurück. Wenn die Eigenschaft nicht vom Typ QTextFormat::LengthVector ist, wird stattdessen eine leere Liste zurückgegeben.

Siehe auch setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(), colorProperty(), lengthProperty(), und Property.

void QTextFormat::merge(const QTextFormat &other)

Mischt das Format other mit diesem Format; bei Konflikten hat das Format other Vorrang.

int QTextFormat::objectIndex() const

Gibt den Index des Format-Objekts zurück, oder -1, wenn das Format-Objekt ungültig ist.

Siehe auch setObjectIndex().

int QTextFormat::objectType() const

Gibt den Objekttyp des Textformats zurück.

Siehe auch ObjectTypes und setObjectType().

QPen QTextFormat::penProperty(int propertyId) const

Gibt den Wert der durch propertyId angegebenen Eigenschaft zurück; wenn die Eigenschaft nicht vom Typ QMetaType::QPen ist, wird stattdessen Qt::NoPen zurückgegeben.

Siehe auch setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(), lengthProperty(), lengthVectorProperty(), und Property.

QMap<int, QVariant> QTextFormat::properties() const

Gibt eine Karte mit allen Eigenschaften dieses Textformats zurück.

QVariant QTextFormat::property(int propertyId) const

Gibt die durch die angegebene propertyId angegebene Eigenschaft zurück.

Siehe auch setProperty() und Property.

int QTextFormat::propertyCount() const

Gibt die Anzahl der im Format gespeicherten Eigenschaften zurück.

void QTextFormat::setBackground(const QBrush &brush)

Setzt den Pinsel, mit dem der Hintergrund des Dokuments gemalt wird, auf die angegebene brush.

Siehe auch background(), clearBackground(), und setForeground().

void QTextFormat::setForeground(const QBrush &brush)

Setzt den Vordergrundpinsel auf den angegebenen brush. Der Vordergrundpinsel wird meist zur Darstellung von Text verwendet.

Siehe auch foreground(), clearForeground(), und setBackground().

void QTextFormat::setLayoutDirection(Qt::LayoutDirection direction)

Setzt die Layout-Richtung des Dokuments auf die angegebene direction.

Siehe auch layoutDirection().

void QTextFormat::setObjectIndex(int index)

Setzt das Objekt des Format-Objekts index.

Siehe auch objectIndex().

void QTextFormat::setObjectType(int type)

Setzt den Objekttyp des Textformats auf type.

Siehe auch ObjectTypes und objectType().

void QTextFormat::setProperty(int propertyId, const QList<QTextLength> &value)

Setzt den Wert der durch propertyId angegebenen Eigenschaft auf value.

Siehe auch property(), lengthVectorProperty(), und Property.

void QTextFormat::setProperty(int propertyId, const QVariant &value)

Setzt die durch propertyId angegebene Eigenschaft auf die angegebene value.

Siehe auch Property.

QString QTextFormat::stringProperty(int propertyId) const

Gibt den Wert der durch propertyId angegebenen Eigenschaft zurück; wenn die Eigenschaft nicht vom Typ QMetaType::QString ist, wird stattdessen ein leerer String zurückgegeben.

Siehe auch setProperty(), boolProperty(), intProperty(), doubleProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), und Property.

void QTextFormat::swap(QTextFormat &other)

Tauscht dieses Textformat mit other aus. Dieser Vorgang ist sehr schnell und schlägt nie fehl.

QTextBlockFormat QTextFormat::toBlockFormat() const

Gibt dieses Format als Blockformat zurück.

QTextCharFormat QTextFormat::toCharFormat() const

Gibt dieses Format als Zeichenformat zurück.

QTextFrameFormat QTextFormat::toFrameFormat() const

Gibt dieses Format als Rahmenformat zurück.

QTextImageFormat QTextFormat::toImageFormat() const

Gibt dieses Format als Bildformat zurück.

QTextListFormat QTextFormat::toListFormat() const

Gibt dieses Format als Listenformat zurück.

QTextTableCellFormat QTextFormat::toTableCellFormat() const

Gibt dieses Format als Tabellenzellenformat zurück.

QTextTableFormat QTextFormat::toTableFormat() const

Gibt dieses Format als Tabellenformat zurück.

int QTextFormat::type() const

Gibt den Typ dieses Formats zurück.

Siehe auch FormatType.

QVariant QTextFormat::operator QVariant() const

Gibt das Textformat als QVariant

bool QTextFormat::operator!=(const QTextFormat &other) const

Gibt true zurück, wenn sich dieses Textformat vom Textformat other unterscheidet.

QTextFormat &QTextFormat::operator=(const QTextFormat &other)

Weist das Textformat other diesem Textformat zu und gibt einen Verweis auf dieses Textformat zurück.

bool QTextFormat::operator==(const QTextFormat &other) const

Gibt true zurück, wenn dieses Textformat mit dem other Textformat identisch ist.

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