📄 qtextformat.cpp
字号:
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*//*! \fn QTextFrameFormat::QTextFrameFormat() Constructs a text frame format object with the default properties.*/QTextFrameFormat::QTextFrameFormat() : QTextFormat(FrameFormat) {}/*! \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::setMargin(qreal margin) Sets the frame's \a margin in pixels.*//*! \fn qreal QTextFrameFormat::margin() const Returns the width of the frame's external margin in pixels.*//*! \fn QTextFrameFormat::setPadding(qreal width) Sets the \a width of the frame's internal padding in pixels.*//*! \fn qreal QTextFrameFormat::padding() const Returns the width of the frame's internal padding in pixels.*//*! \fn QTextFrameFormat::setWidth(const QTextLength &width) Sets the frame's border rectangle's \a width. \sa QTextLength*//*! \fn QTextFrameFormat::setWidth(qreal width) \overload Convenience method that sets the width of the frame's border rectangle's width to the specified fixed \a width.*//*! \fn QTextLength QTextFrameFormat::width() const Returns the width of the frame's border rectangle. \sa QTextLength*//*! \fn void QTextFrameFormat::setHeight(const QTextLength &height) Sets the frame's \a height.*//*! \fn void QTextFrameFormat::setHeight(qreal height) \overload Sets the frame's \a height.*//*! \fn qreal QTextFrameFormat::height() const Returns the height of the frame's border rectangle.*//*! \class QTextTableFormat qtextformat.h \brief The QTextTableFormat class provides formatting information for tables in a QTextDocument. \ingroup text A table is a group of cells ordered into rows and columns. Each table contains at least one row and one column. Each cell contains a block. Tables in rich text documents are formatted using the properties defined in this class. Tables are horizontally justified within their parent frame according to the table's alignment. This can be read with the alignment() function and set with setAlignment(). Cells within the table are separated by cell spacing. The number of pixels between cells is set with setCellSpacing() and read with cellSpacing(). The contents of each cell is surrounded by cell padding. The number of pixels between each cell edge and its contents is set with setCellPadding() and read with cellPadding(). \image qtexttableformat-cell.png The table's background color can be read with the backgroundColor() function, and can be specified with setBackgroundColor(). The background color of each cell can be set independently, and will control the color of the cell within the padded area. The table format also provides a way to constrain the widths of the columns in the table. Columns can be assigned a fixed width, a variable width, or a percentage of the available width (see QTextLength). The columns() function returns the number of columns with constraints, and the columnWidthConstraints() function returns the constraints defined for the table. These quantities can also be set by calling setColumnWidthConstraints() with a vector containing new constraints. The setColumns() function can be used to change the number of constraints in use. If no constraints are required, clearColumnWidthConstraints() can be used to remove them. \sa QTextTable QTextTableCell QTextLength*//*! \fn QTextTableFormat::QTextTableFormat() Constructs a new table format object.*/QTextTableFormat::QTextTableFormat() : QTextFrameFormat(){ setObjectType(TableObject); setCellSpacing(2); setBorder(1);}/*! \fn bool QTextTableFormat::isValid() const Returns true if this table format is valid; otherwise returns false.*//*! \fn int QTextTableFormat::columns() const Returns the number of columns specified by the table format. \sa setColumns()*//*! \fn void QTextTableFormat::setColumns(int columns) Sets the number of \a columns required by the table format. \sa columns()*//*! \fn void QTextTableFormat::clearColumnWidthConstraints() Clears the column width constraints for the table. \sa columnWidthConstraints() setColumnWidthConstraints()*//*! \fn void QTextTableFormat::setColumnWidthConstraints(const QVector<QTextLength> &constraints) Sets the column width \a constraints for the table. \sa columnWidthConstraints() clearColumnWidthConstraints()*//*! \fn QVector<QTextLength> QTextTableFormat::columnWidthConstraints() const Returns a list of constraints used by this table format to control the appearance of columns in a table. \sa setColumnWidthConstraints()*//*! \fn qreal QTextTableFormat::cellSpacing() const Returns the table's cell spacing. This describes the distance between adjacent cells.*//*! \fn void QTextTableFormat::setCellSpacing(qreal spacing) Sets the cell \a spacing for the table. This determines the distance between adjacent cells.*//*! \fn qreal QTextTableFormat::cellPadding() const Returns the table's cell padding. This describes the distance between the border of a cell and its contents.*//*! \fn void QTextTableFormat::setCellPadding(qreal padding) Sets the cell \a padding for the table. This determines the distance between the border of a cell and its contents.*//*! \fn void QTextTableFormat::setAlignment(Qt::Alignment alignment) Sets the table's \a alignment. \sa alignment()*//*! \fn Qt::Alignment QTextTableFormat::alignment() const Returns the table's alignment. \sa setAlignment()*//*! \fn void QTextFormat::setBackground(const QBrush &brush) Sets the brush use to paint the document's background to the \a brush specified. \sa background() clearBackground() setForeground()*//*! \fn QColor QTextFormat::background() const Returns the brush used to paint the document's background. \sa setBackground() clearBackground() foreground()*//*! \fn void QTextFormat::clearBackground() Clears the brush used to paint the document's background. The default brush will be used. \sa background() setBackground() clearForeground()*//*! \class QTextImageFormat qtextformat.h \brief The QTextImageFormat class provides formatting information for images in a QTextDocument. \ingroup text Inline images are represented by an object replacement character (0xFFFC in Unicode) which has an associated QTextImageFormat. The image format specifies a name with setName() that is used to locate the image. The size of the rectangle that the image will occupy is specified using setWidth() and setHeight().*//*! \fn QTextImageFormat::QTextImageFormat() Creates a new image format object.*/QTextImageFormat::QTextImageFormat() : QTextCharFormat() { setObjectType(ImageObject); }/*! \fn bool QTextImageFormat::isValid() const Returns true if this image format is valid; otherwise returns false.*//*! \fn void QTextImageFormat::setName(const QString &name) Sets the \a name of the image. The \a name is used to locate the image in the application's resources. \sa name()*//*! \fn QString QTextImageFormat::name() const Returns the name of the image. The name refers to an entry in the application's resources file. \sa setName()*//*! \fn void QTextImageFormat::setWidth(qreal width) Sets the \a width of the rectangle occupied by the image. \sa width() setHeight()*//*! \fn qreal QTextImageFormat::width() const Returns the width of the rectangle occupied by the image. \sa height() setWidth()*//*! \fn void QTextImageFormat::setHeight(qreal height) Sets the \a height of the rectangle occupied by the image. \sa height() setWidth()*//*! \fn qreal QTextImageFormat::height() const Returns the height of the rectangle occupied by the image. \sa width() setHeight()*/// ------------------------------------------------------QTextFormatCollection::QTextFormatCollection(const QTextFormatCollection &rhs){ formats = rhs.formats; objFormats = rhs.objFormats;}QTextFormatCollection &QTextFormatCollection::operator=(const QTextFormatCollection &rhs){ formats = rhs.formats; objFormats = rhs.objFormats; return *this;}QTextFormatCollection::~QTextFormatCollection(){}int QTextFormatCollection::indexForFormat(const QTextFormat &format){ uint hash = format.d ? format.d->hash() : 0; if (hashes.contains(hash)) { for (int i = 0; i < formats.size(); ++i) { if (formats.at(i) == format) return i; } } int idx = formats.size(); formats.append(format); QTextFormat &f = formats.last(); if (!f.d) f.d = new QTextFormatPrivate; f.d->resolveFont(defaultFnt); hashes.insert(hash); return idx;}bool QTextFormatCollection::hasFormatCached(const QTextFormat &format) const{ uint hash = format.d ? format.d->hash() : 0; if (hashes.contains(hash)) { for (int i = 0; i < formats.size(); ++i) if (formats.at(i) == format) return true; } return false;}QTextFormat QTextFormatCollection::objectFormat(int objectIndex) const{ if (objectIndex == -1) return QTextFormat(); return format(objFormats.at(objectIndex));}void QTextFormatCollection::setObjectFormat(int objectIndex, const QTextFormat &f){ const int formatIndex = indexForFormat(f); objFormats[objectIndex] = formatIndex;}int QTextFormatCollection::objectFormatIndex(int objectIndex) const{ if (objectIndex == -1) return -1; return objFormats.at(objectIndex);}void QTextFormatCollection::setObjectFormatIndex(int objectIndex, int formatIndex){ objFormats[objectIndex] = formatIndex;}int QTextFormatCollection::createObjectIndex(const QTextFormat &f){ const int objectIndex = objFormats.size(); objFormats.append(indexForFormat(f)); return objectIndex;}QTextFormat QTextFormatCollection::format(int idx) const{ if (idx < 0 || idx >= formats.count()) return QTextFormat(); return formats.at(idx);}void QTextFormatCollection::setDefaultFont(const QFont &f){ defaultFnt = f; for (int i = 0; i < formats.count(); ++i) if (formats[i].d) formats[i].d->resolveFont(defaultFnt);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -