📄 qtextformat.cpp
字号:
/*! \fn bool QTextCharFormat::fontUnderline() const Returns true if the text format's font is underlined; otherwise returns false. \sa font()*//*! \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 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 setAnchorName() 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() setAnchorName()*//*! \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 setAnchorName(). 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) 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 QString QTextCharFormat::anchorName() const 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.*//*! \fn void QTextCharFormat::setTableCellRowSpan(int tableCellRowSpan) If this character format is applied to characters in a table cell, the cell will span \a tableCellRowSpan rows.*//*! \fn int QTextCharFormat::tableCellRowSpan() const 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) If this character format is applied to characters in a table cell, the cell will span \a tableCellColumnSpan columns.*//*! \fn int QTextCharFormat::tableCellColumnSpan() const 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()*//*! \fn void QTextCharFormat::setVerticalAlignment(VerticalAlignment alignment) Sets the vertical alignment used for the characters with this format to the \a alignment specified. \sa verticalAlignment()*//*! \fn VerticalAlignment QTextCharFormat::verticalAlignment() const Returns the vertical alignment used for characters with this format. \sa setVerticalAlignment()*//*! Sets the text format's \a font.*/void QTextCharFormat::setFont(const QFont &font){ setFontFamily(font.family()); const qreal pointSize = font.pointSizeF(); if (pointSize > 0) { setFontPointSize(pointSize); } else { const int pixelSize = font.pixelSize(); if (pixelSize > 0) setProperty(QTextFormat::FontPixelSize, pixelSize); } setFontWeight(font.weight()); setFontItalic(font.italic()); setFontUnderline(font.underline()); setFontOverline(font.overline()); setFontStrikeOut(font.strikeOut()); setFontFixedPitch(font.fixedPitch());}/*! Returns the font for this character format.*/QFont QTextCharFormat::font() const{ return d ? d->font() : QFont();}/*! \class QTextBlockFormat qtextformat.h \brief The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument. \ingroup text A document is composed of a list of blocks. Each block can contain an item of some kind, such as a paragraph of text, a table, a list, or an image. Every block has an associated QTextBlockFormat that specifies its characteristics. To cater for left-to-right and right-to-left languages you can set a block's direction with setDirection(). Paragraph alignment is set with setAlignment(). Margins are controlled by setTopMargin(), setBottomMargin(), setLeftMargin(), setRightMargin(). Overall indentation is set with setIndent(), the indentation of the first line with setTextIndent(). Line breaking can be enabled and disabled with setNonBreakableLines(). The brush used to paint the paragraph's background is set with \l{QTextFormat::setBackground()}{setBackground()}, and other aspects of the text's appearance can be customized by using the \l{QTextFormat::setProperty()}{setProperty()} function with the \c OutlinePen, \c ForegroundBrush, and \c BackgroundBrush \l{QTextFormat::Property} values. If a text block is part of a list, it can also have a list format that is accessible with the listFormat() function. \sa QTextCharFormat*//*! \fn QTextBlockFormat::QTextBlockFormat() Constructs a new QTextBlockFormat.*/QTextBlockFormat::QTextBlockFormat() : QTextFormat(BlockFormat) {}/*! \fn QTextBlockFormat::isValid() const Returns true if this block format is valid; otherwise returns false.*//*! \fn void QTextFormat::setLayoutDirection(Qt::LayoutDirection direction) Sets the document's layout direction to the specified \a direction. \sa layoutDirection()*//*! \fn Qt::LayoutDirection QTextFormat::layoutDirection() const Returns the document's layout direction. \sa setLayoutDirection()*//*! \fn void QTextBlockFormat::setAlignment(Qt::Alignment alignment) Sets the paragraph's \a alignment. \sa alignment()*//*! \fn Qt::Alignment QTextBlockFormat::alignment() const Returns the paragraph's alignment. \sa setAlignment()*//*! \fn void QTextBlockFormat::setTopMargin(qreal margin) Sets the paragraph's top \a margin. \sa topMargin() setBottomMargin() setLeftMargin() setRightMargin()*//*! \fn qreal QTextBlockFormat::topMargin() const Returns the paragraph's top margin. \sa setTopMargin() bottomMargin()*//*! \fn void QTextBlockFormat::setBottomMargin(qreal margin) Sets the paragraph's bottom \a margin. \sa bottomMargin() setTopMargin() setLeftMargin() setRightMargin()*//*! \fn qreal QTextBlockFormat::bottomMargin() const Returns the paragraph's bottom margin. \sa setBottomMargin() topMargin()*//*! \fn void QTextBlockFormat::setLeftMargin(qreal margin) Sets the paragraph's left \a margin. Indentation can be applied separately with setIndent(). \sa leftMargin() setRightMargin() setTopMargin() setBottomMargin()*//*! \fn qreal QTextBlockFormat::leftMargin() const Returns the paragraph's left margin. \sa setLeftMargin() rightMargin() indent()*//*! \fn void QTextBlockFormat::setRightMargin(qreal margin) Sets the paragraph's right \a margin. \sa rightMargin() setLeftMargin() setTopMargin() setBottomMargin()*//*! \fn qreal QTextBlockFormat::rightMargin() const Returns the paragraph's right margin. \sa setRightMargin() leftMargin()*//*! \fn void QTextBlockFormat::setTextIndent(qreal indent) Sets the \a indent for the first line in the block. This allows the first line of a paragraph to be indented differently to the other lines, enhancing the readability of the text. \sa textIndent() setLeftMargin() setRightMargin() setTopMargin() setBottomMargin()*//*! \fn qreal QTextBlockFormat::textIndent() const Returns the paragraph's text indent. \sa setTextIndent()*//*! \fn void QTextBlockFormat::setIndent(int indentation) Sets the paragraph's \a indentation. Margins are set independently of indentation with setLeftMargin() and setTextIdent(). \sa indent()*//*! \fn int QTextBlockFormat::indent() const Returns the paragraph's indent. \sa setIndent()*//*! \fn void QTextBlockFormat::setNonBreakableLines(bool b) If \a b is true, the lines in the paragraph are treated as non-breakable; otherwise they are breakable. \sa nonBreakableLines()*//*! \fn bool QTextBlockFormat::nonBreakableLines() const Returns true if the lines in the paragraph are non-breakable; otherwise returns false. \sa setNonBreakableLines()*//*! \class QTextListFormat qtextformat.h \brief The QTextListFormat class provides formatting information for lists in a QTextDocument. \ingroup text A list is composed of one or more items, represented as text blocks. The list's format specifies the appearance of items in the list. In particular, it determines the indentation and the style of each item. The indentation of the items is an integer value that causes each item to be offset from the left margin by a certain amount. This value is read with indent() and set with setIndent(). The style used to decorate each item is set with setStyle() and can be read with the style() function. The style controls the type of bullet points and numbering scheme used for items in the list. Note that lists that use the decimal numbering scheme begin counting at 1 rather than 0. \sa QTextList*//*! \enum QTextListFormat::Style This enum describes the symbols used to decorate list items: \value ListDisc a filled circle \value ListCircle an empty circle \value ListSquare a filled square \value ListDecimal decimal values in ascending order \value ListLowerAlpha lower case Latin characters in alphabetical order \value ListUpperAlpha upper case Latin characters in alphabetical order \omitvalue ListStyleUndefined*//*! \fn QTextListFormat::QTextListFormat() Constructs a new list format object.*/QTextListFormat::QTextListFormat() : QTextFormat(ListFormat){ setIndent(1);}/*! \fn bool QTextListFormat::isValid() const Returns true if this list format is valid; otherwise
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -