📄 qtextformat.cpp
字号:
/*! \fn qreal QTextFrameFormat::margin() const Returns the width of the frame's external margin in pixels.*//*! \fn QTextFrameFormat::setTopMargin(qreal margin) \since 4.3 Sets the frame's top \a margin in pixels.*//*! \fn qreal QTextFrameFormat::topMargin() const \since 4.3 Returns the width of the frame's top margin in pixels.*/qreal QTextFrameFormat::topMargin() const{ if (!hasProperty(FrameTopMargin)) return margin(); return doubleProperty(FrameTopMargin);}/*! \fn QTextFrameFormat::setBottomMargin(qreal margin) \since 4.3 Sets the frame's bottom \a margin in pixels.*//*! \fn qreal QTextFrameFormat::bottomMargin() const \since 4.3 Returns the width of the frame's bottom margin in pixels.*/qreal QTextFrameFormat::bottomMargin() const{ if (!hasProperty(FrameBottomMargin)) return margin(); return doubleProperty(FrameBottomMargin);}/*! \fn QTextFrameFormat::setLeftMargin(qreal margin) \since 4.3 Sets the frame's left \a margin in pixels.*//*! \fn qreal QTextFrameFormat::leftMargin() const \since 4.3 Returns the width of the frame's left margin in pixels.*/qreal QTextFrameFormat::leftMargin() const{ if (!hasProperty(FrameLeftMargin)) return margin(); return doubleProperty(FrameLeftMargin);}/*! \fn QTextFrameFormat::setRightMargin(qreal margin) \since 4.3 Sets the frame's right \a margin in pixels.*//*! \fn qreal QTextFrameFormat::rightMargin() const \since 4.3 Returns the width of the frame's right margin in pixels.*/qreal QTextFrameFormat::rightMargin() const{ if (!hasProperty(FrameRightMargin)) return margin(); return doubleProperty(FrameRightMargin);}/*! \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 QTextFormat::PageBreakFlags QTextFrameFormat::pageBreakPolicy() const \since 4.2 Returns the currently set page break policy for the frame/table. The default is QTextFormat::PageBreak_Auto. \sa setPageBreakPolicy()*//*! \fn void QTextFrameFormat::setPageBreakPolicy(PageBreakFlags policy) \since 4.2 Sets the page break policy for the frame/table to \a policy. \sa pageBreakPolicy()*//*! \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 \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 background() function, and can be specified with setBackground(). 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. 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.*//*! \internal \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 QTextTableFormat::setHeaderRowCount(int count) \since 4.2 Declares the first \a count rows of the table as table header. The table header rows get repeated when a table is broken across a page boundary.*//*! \fn int QTextTableFormat::headerRowCount() const \since 4.2 Returns the number of rows in the table that define the header. \sa setHeaderRowCount()*//*! \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 \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 QTextFormatCo
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -