📄 qtextformat.cpp
字号:
Returns the number of properties stored in the format.*/int QTextFormat::propertyCount() const{ return d ? d->props.count() : 0;}/*! \fn bool QTextFormat::operator!=(const QTextFormat &other) const Returns true if this text format is different from the \a other text format.*//*! \fn bool QTextFormat::operator==(const QTextFormat &other) const Returns true if this text format is the same as the \a other text format.*/bool QTextFormat::operator==(const QTextFormat &rhs) const{ if (format_type != rhs.format_type) return false; if (d == rhs.d) return true; if (d && d->props.isEmpty() && !rhs.d) return true; if (!d && rhs.d && rhs.d->props.isEmpty()) return true; if (!d || !rhs.d) return false; return *d == *rhs.d;}/*! \class QTextCharFormat \brief The QTextCharFormat class provides formatting information for characters in a QTextDocument. \ingroup text The character format of text in a document specifies the visual properties of the text, as well as information about its role in a hypertext document. The font used can be set by supplying a font to the setFont() function, and each aspect of its appearance can be adjusted to give the desired effect. setFontFamily() and setFontPointSize() define the font's family (e.g. Times) and printed size; setFontWeight() and setFontItalic() provide control over the style of the font. setFontUnderline(), setFontOverline(), setFontStrikeOut(), and setFontFixedPitch() provide additional effects for text. The color is set with setForeground(). If the text is intended to be used as an anchor (for hyperlinks), this can be enabled with setAnchor(). The setAnchorHref() and setAnchorNames() functions are used to specify the information about the hyperlink's destination and the anchor's name. \sa QTextFormat QTextBlockFormat QTextTableFormat QTextListFormat*//*! \enum QTextCharFormat::VerticalAlignment This enum describes the ways that adjacent characters can be vertically aligned. \value AlignNormal Adjacent characters are positioned in the standard way for text in the writing system in use. \value AlignSuperScript Characters are placed above the baseline for normal text. \value AlignSubScript Characters are placed below the baseline for normal text. \value AlignMiddle This is currently only implemented for inline objects. The center of the object is vertically aligned with the base line. \value AlignBottom The bottom edge of the object is vertically aligned with the base line. \value AlignTop The top edge of the object is vertically aligned with the base line.*//*! \enum QTextCharFormat::UnderlineStyle This enum describes the different ways drawing underlined text. \value NoUnderline Text is draw without any underlining decoration. \value SingleUnderline A line is drawn using Qt::SolidLine. \value DashUnderline Dashes are drawn using Qt::DashLine. \value DotLine Dots are drawn using Qt::DotLine; \value DashDotLine Dashs and dots are drawn using Qt::DashDotLine. \value DashDotDotLine Underlines draw drawn using Qt::DashDotDotLine. \value WaveUnderline The text is underlined using a wave shaped line. \value SpellCheckUnderline The underline is drawn depending on the QStyle::SH_SpellCeckUnderlineStyle style hint of the QApplication style. By default this is mapped to WaveUnderline, on Mac OS X it is mapped to DashDotLine. \sa Qt::PenStyle*//*! \fn QTextCharFormat::QTextCharFormat() Constructs a new character format object.*/QTextCharFormat::QTextCharFormat() : QTextFormat(CharFormat) {}/*! \fn bool QTextCharFormat::isValid() const Returns true if this character format is valid; otherwise returns false.*//*! \fn void QTextCharFormat::setFontFamily(const QString &family) Sets the text format's font \a family. \sa setFont()*//*! \fn QString QTextCharFormat::fontFamily() const Returns the text format's font family. \sa font()*//*! \fn void QTextCharFormat::setFontPointSize(qreal size) Sets the text format's font \a size. \sa setFont()*//*! \fn qreal QTextCharFormat::fontPointSize() const Returns the font size used to display text in this format. \sa font()*//*! \fn void QTextCharFormat::setFontWeight(int weight) Sets the text format's font weight to \a weight. \sa setFont(), QFont::Weight*//*! \fn int QTextCharFormat::fontWeight() const Returns the text format's font weight. \sa font(), QFont::Weight*//*! \fn void QTextCharFormat::setFontItalic(bool italic) If \a italic is true, sets the text format's font to be italic; otherwise the font will be non-italic. \sa setFont()*//*! \fn bool QTextCharFormat::fontItalic() const Returns true if the text format's font is italic; otherwise returns false. \sa font()*//*! \fn void QTextCharFormat::setFontUnderline(bool underline) If \a underline is true, sets the text format's font to be underlined; otherwise it is displayed non-underlined. \sa setFont()*//*! \fn bool QTextCharFormat::fontUnderline() const Returns true if the text format's font is underlined; otherwise returns false. \sa font()*/bool QTextCharFormat::fontUnderline() const{ if (hasProperty(TextUnderlineStyle)) return underlineStyle() == SingleUnderline; return boolProperty(FontUnderline);}/*! \fn UnderlineStyle QTextCharFormat::underlineStyle() const \since 4.2 Returns the style of underlining the text.*//*! \fn void QTextCharFormat::setUnderlineStyle(UnderlineStyle style) \since 4.2 Sets the style of underlining the text to \a style.*/void QTextCharFormat::setUnderlineStyle(UnderlineStyle style){ setProperty(TextUnderlineStyle, style); // for compatibility setProperty(FontUnderline, style == SingleUnderline);}/*! \fn void QTextCharFormat::setFontOverline(bool overline) If \a overline is true, sets the text format's font to be overlined; otherwise the font is displayed non-overlined. \sa setFont()*//*! \fn bool QTextCharFormat::fontOverline() const Returns true if the text format's font is overlined; otherwise returns false. \sa font()*//*! \fn void QTextCharFormat::setFontStrikeOut(bool strikeOut) If \a strikeOut is true, sets the text format's font with strike-out enabled (with a horizontal line through it); otherwise it is displayed without strikeout. \sa setFont()*//*! \fn bool QTextCharFormat::fontStrikeOut() const Returns true if the text format's font is struck out (has a horizontal line drawn through it); otherwise returns false. \sa font()*//*! \fn void QTextCharFormat::setFontFixedPitch(bool fixedPitch) If \a fixedPitch is true, sets the text format's font to be fixed pitch; otherwise a non-fixed pitch font is used. \sa setFont()*//*! \fn bool QTextCharFormat::fontFixedPitch() const Returns true if the text format's font is fixed pitch; otherwise returns false. \sa font()*//*! \fn QPen QTextCharFormat::textOutline() const Returns the pen used to draw the outlines of characters in this format.*//*! \fn void QTextCharFormat::setTextOutline(const QPen &pen) Sets the pen used to draw the outlines of characters to the given \a pen.*//*! \fn void QTextCharFormat::setToolTip(const QString &text) \since 4.3 Sets the tool tip for a fragment of text to the given \a text.*//*! \fn QString QTextCharFormat::toolTip() const \since 4.3 Returns the tool tip that is displayed for a fragment of text.*//*! \fn void QTextFormat::setForeground(const QBrush &brush) Sets the foreground brush to the specified \a brush. The foreground brush is mostly used to render text. \sa foreground() clearForeground() setBackground()*//*! \fn QBrush QTextFormat::foreground() const Returns the brush used to render foreground details, such as text, frame outlines, and table borders. \sa setForeground() clearForeground() background()*//*! \fn void QTextFormat::clearForeground() Clears the brush used to paint the document's foreground. The default brush will be used. \sa foreground() setForeground() clearBackground()*//*! \fn void QTextCharFormat::setAnchor(bool anchor) If \a anchor is true, text with this format represents an anchor, and is formatted in the appropriate way; otherwise the text is formatted normally. (Anchors are hyperlinks which are often shown underlined and in a different color from plain text.) The way the text is rendered is independent of whether or not the format has a valid anchor defined. Use setAnchorHref(), and optionally setAnchorNames() to create a hypertext link. \sa isAnchor()*//*! \fn bool QTextCharFormat::isAnchor() const Returns true if the text is formatted as an anchor; otherwise returns false. \sa setAnchor() setAnchorHref() setAnchorNames()*//*! \fn void QTextCharFormat::setAnchorHref(const QString &value) Sets the hypertext link for the text format to the given \a value. This is typically a URL like "http://www.trolltech.com/index.html". The anchor will be displayed with the \a value as its display text; if you want to display different text call setAnchorNames(). To format the text as a hypertext link use setAnchor().*//*! \fn QString QTextCharFormat::anchorHref() const Returns the text format's hypertext link, or an empty string if none has been set.*//*! \fn void QTextCharFormat::setAnchorName(const QString &name) \obsolete This function is deprecated. Use setAnchorNames() instead. Sets the text format's anchor \a name. For the anchor to work as a hyperlink, the destination must be set with setAnchorHref() and the anchor must be enabled with setAnchor().*//*! \fn void QTextCharFormat::setAnchorNames(const QStringList &names) \since 4.3 Sets the text format's anchor \a names. For the anchor to work as a hyperlink, the destination must be set with setAnchorHref() and the anchor must be enabled with setAnchor().*//*! \fn QString QTextCharFormat::anchorName() const \obsolete This function is deprecated. Use anchorNames() instead. Returns the anchor name associated with this text format, or an empty string if none has been set. If the anchor name is set, text with this format can be the destination of a hypertext link.*/QString QTextCharFormat::anchorName() const{ QVariant prop = property(AnchorName); if (prop.type() == QVariant::StringList) return prop.toStringList().value(0); else if (prop.type() != QVariant::String) return QString(); return prop.toString();}/*! \fn QStringList QTextCharFormat::anchorNames() const \since 4.3 Returns the anchor names associated with this text format, or an empty string list if none has been set. If the anchor names are set, text with this format can be the destination of a hypertext link.*/QStringList QTextCharFormat::anchorNames() const{ QVariant prop = property(AnchorName); if (prop.type() == QVariant::StringList) return prop.toStringList(); else if (prop.type() != QVariant::String) return QStringList(); return QStringList(prop.toString());}/*! \fn void QTextCharFormat::setTableCellRowSpan(int tableCellRowSpan) \internal If this character format is applied to characters in a table cell, the cell will span \a tableCellRowSpan rows.*//*! \fn int QTextCharFormat::tableCellRowSpan() const \internal If this character format is applied to characters in a table cell, this function returns the number of rows spanned by the text (this may be 1); otherwise it returns 1.*//*! \fn void QTextCharFormat::setTableCellColumnSpan(int tableCellColumnSpan) \internal If this character format is applied to characters in a table cell, the cell will span \a tableCellColumnSpan columns.*//*! \fn int QTextCharFormat::tableCellColumnSpan() const \internal If this character format is applied to characters in a table cell, this function returns the number of columns spanned by the text (this may be 1); otherwise it returns 1.*//*! \fn void QTextCharFormat::setUnderlineColor(const QColor &color) Sets the underline color used for the characters with this format to the \a color specified. \sa underlineColor()*//*! \fn QColor QTextCharFormat::underlineColor() const Returns the color used to underline the characters with this format. \sa setUnderlineColor()*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -