📄 qtextformat.cpp
字号:
/*! \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()); setUnderlineStyle(font.underline() ? SingleUnderline : NoUnderline); 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 \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, represented by QTextBlock objects. 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 QTextBlock, 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()*//*! \fn QTextFormat::PageBreakFlags QTextBlockFormat::pageBreakPolicy() const \since 4.2 Returns the currently set page break policy for the paragraph. The default is QTextFormat::PageBreak_Auto. \sa setPageBreakPolicy()*//*! \fn void QTextBlockFormat::setPageBreakPolicy(PageBreakFlags policy) \since 4.2 Sets the page break policy for the paragraph to \a policy. \sa pageBreakPolicy()*//*! \class QTextListFormat \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 returns false.*//*! \fn void QTextListFormat::setStyle(Style style) Sets the list format's \a style. See \c{Style} for the available styles. \sa style()*//*! \fn Style QTextListFormat::style() const Returns the list format's style. See \c{Style}. \sa setStyle()*//*! \fn void QTextListFormat::setIndent(int indentation) Sets the list format's \a indentation. \sa indent()*//*! \fn int QTextListFormat::indent() const Returns the list format's indentation. \sa setIndent()*//*! \class QTextFrameFormat \brief The QTextFrameFormat class provides formatting information for frames in a QTextDocument. \ingroup text A text frame groups together one or more blocks of text, providing a layer of structure larger than the paragraph. The format of a frame specifies how it is rendered and positioned on the screen. It does not directly specify the behavior of the text formatting within, but provides constraints on the layout of its children. The frame format defines the width() and height() of the frame on the screen. Each frame can have a border() that surrounds its contents with a rectangular box. The border is surrounded by a margin() around the frame, and the contents of the frame are kept separate from the border by the frame's padding(). This scheme is similar to the box model used by Cascading Style Sheets for HTML pages. \img qtextframe-style.png The position() of a frame is set using setPosition() and determines how it is located relative to the surrounding text. The validity of a QTextFrameFormat object can be determined with the isValid() function. \sa QTextFrame QTextBlockFormat*//*! \enum QTextFrameFormat::Position \value InFlow \value FloatLeft \value FloatRight*//*! \enum QTextFrameFormat::BorderStyle \since 4.3 \value BorderStyle_None \value BorderStyle_Dotted \value BorderStyle_Dashed \value BorderStyle_Solid \value BorderStyle_Double \value BorderStyle_DotDash \value BorderStyle_DotDotDash \value BorderStyle_Groove \value BorderStyle_Ridge \value BorderStyle_Inset \value BorderStyle_Outset*//*! \fn QTextFrameFormat::QTextFrameFormat() Constructs a text frame format object with the default properties.*/QTextFrameFormat::QTextFrameFormat() : QTextFormat(FrameFormat){ setBorderStyle(BorderStyle_Outset); setBorderBrush(Qt::darkGray);}/*! \fn QTextFrameFormat::isValid() const Returns true if the format description is valid; otherwise returns false.*//*! \fn QTextFrameFormat::setPosition(Position policy) Sets the \a policy for positioning frames with this frame format.*//*! \fn Position QTextFrameFormat::position() const Returns the positioning policy for frames with this frame format.*//*! \fn QTextFrameFormat::setBorder(qreal width) Sets the \a width (in pixels) of the frame's border.*//*! \fn qreal QTextFrameFormat::border() const Returns the width of the border in pixels.*//*! \fn QTextFrameFormat::setBorderBrush(const QBrush &brush) \since 4.3 Sets the \a brush used for the frame's border.*//*! \fn QBrush QTextFrameFormat::borderBrush() const \since 4.3 Returns the brush used for the frame's border.*//*! \fn QTextFrameFormat::setBorderStyle(BorderStyle style) \since 4.3 Sets the \a style of the frame's border.*//*! \fn BorderStyle QTextFrameFormat::borderStyle() const \since 4.3 Returns the style of the frame's border.*//*! \fn QTextFrameFormat::setMargin(qreal margin) Sets the frame's \a margin in pixels. This method also sets the left, right, top and bottom margins of the frame to the same value. The individual margins override the general margin.*/void QTextFrameFormat::setMargin(qreal amargin){ setProperty(FrameMargin, amargin); setProperty(FrameTopMargin, amargin); setProperty(FrameBottomMargin, amargin); setProperty(FrameLeftMargin, amargin); setProperty(FrameRightMargin, amargin);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -