Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QTextTableFormat Class Reference

\reentrant More...

#include <qtextformat.h>

+ Inheritance diagram for QTextTableFormat:
+ Collaboration diagram for QTextTableFormat:

Public Member Functions

 QTextTableFormat ()
 Constructs a new table format object.
 
bool isValid () const
 Returns true if this table format is valid; otherwise returns false.
 
int columns () const
 Returns the number of columns specified by the table format.
 
void setColumns (int columns)
 
void setColumnWidthConstraints (const QList< QTextLength > &constraints)
 Sets the column width constraints for the table.
 
QList< QTextLengthcolumnWidthConstraints () const
 Returns a list of constraints used by this table format to control the appearance of columns in a table.
 
void clearColumnWidthConstraints ()
 Clears the column width constraints for the table.
 
qreal cellSpacing () const
 Returns the table's cell spacing.
 
void setCellSpacing (qreal spacing)
 Sets the cell spacing for the table.
 
qreal cellPadding () const
 Returns the table's cell padding.
 
void setCellPadding (qreal padding)
 Sets the cell padding for the table.
 
void setAlignment (Qt::Alignment alignment)
 Sets the table's alignment.
 
Qt::Alignment alignment () const
 Returns the table's alignment.
 
void setHeaderRowCount (int count)
 
int headerRowCount () const
 
void setBorderCollapse (bool borderCollapse)
 
bool borderCollapse () const
 
- Public Member Functions inherited from QTextFrameFormat
 QTextFrameFormat ()
 Constructs a text frame format object with the default properties.
 
bool isValid () const
 Returns true if the format description is valid; otherwise returns false.
 
void setPosition (Position f)
 Sets the policy for positioning frames with this frame format.
 
Position position () const
 Returns the positioning policy for frames with this frame format.
 
void setBorder (qreal border)
 Sets the width (in pixels) of the frame's border.
 
qreal border () const
 Returns the width of the border in pixels.
 
void setBorderBrush (const QBrush &brush)
 
QBrush borderBrush () const
 
void setBorderStyle (BorderStyle style)
 
BorderStyle borderStyle () const
 
void setMargin (qreal margin)
 Sets the frame's margin in pixels.
 
qreal margin () const
 Returns the width of the frame's external margin in pixels.
 
void setTopMargin (qreal margin)
 
qreal topMargin () const
 
void setBottomMargin (qreal margin)
 
qreal bottomMargin () const
 
void setLeftMargin (qreal margin)
 
qreal leftMargin () const
 
void setRightMargin (qreal margin)
 
qreal rightMargin () const
 
void setPadding (qreal padding)
 Sets the width of the frame's internal padding in pixels.
 
qreal padding () const
 Returns the width of the frame's internal padding in pixels.
 
void setWidth (qreal width)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Convenience method that sets the width of the frame's border rectangle's width to the specified fixed width.
 
void setWidth (const QTextLength &length)
 Sets the frame's border rectangle's width.
 
QTextLength width () const
 Returns the width of the frame's border rectangle.
 
void setHeight (qreal height)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the frame's height.
 
void setHeight (const QTextLength &height)
 Sets the frame's height.
 
QTextLength height () const
 Returns the height of the frame's border rectangle.
 
void setPageBreakPolicy (PageBreakFlags flags)
 
PageBreakFlags pageBreakPolicy () const
 
- Public Member Functions inherited from QTextFormat
 QTextFormat ()
 Creates a new text format with an InvalidFormat.
 
 QTextFormat (int type)
 Creates a new text format of the given type.
 
 QTextFormat (const QTextFormat &rhs)
 Creates a new text format with the same attributes as the other text format.
 
QTextFormatoperator= (const QTextFormat &rhs)
 Assigns the other text format to this text format, and returns a reference to this text format.
 
 ~QTextFormat ()
 Destroys this text format.
 
void swap (QTextFormat &other)
 
void merge (const QTextFormat &other)
 Merges the other format with this format; where there are conflicts the other format takes precedence.
 
bool isValid () const
 Returns true if the format is valid (i.e.
 
bool isEmpty () const
 
int type () const
 Returns the type of this format.
 
int objectIndex () const
 Returns the index of the format object, or -1 if the format object is invalid.
 
void setObjectIndex (int object)
 Sets the format object's object index.
 
QVariant property (int propertyId) const
 Returns the property specified by the given propertyId.
 
void setProperty (int propertyId, const QVariant &value)
 Sets the property specified by the propertyId to the given value.
 
void clearProperty (int propertyId)
 Clears the value of the property given by propertyId.
 
bool hasProperty (int propertyId) const
 Returns true if the text format has a property with the given propertyId; otherwise returns false.
 
bool boolProperty (int propertyId) const
 Returns the value of the property specified by propertyId.
 
int intProperty (int propertyId) const
 Returns the value of the property specified by propertyId.
 
qreal doubleProperty (int propertyId) const
 Returns the value of the property specified by propertyId.
 
QString stringProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QMetaType::QString type, an empty string is returned instead.
 
QColor colorProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QMetaType::QColor type, an invalid color is returned instead.
 
QPen penProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QMetaType::QPen type, Qt::NoPen is returned instead.
 
QBrush brushProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QMetaType::QBrush type, Qt::NoBrush is returned instead.
 
QTextLength lengthProperty (int propertyId) const
 Returns the value of the property given by propertyId.
 
QList< QTextLengthlengthVectorProperty (int propertyId) const
 Returns the value of the property given by propertyId.
 
void setProperty (int propertyId, const QList< QTextLength > &lengths)
 Sets the value of the property given by propertyId to value.
 
QMap< int, QVariantproperties () const
 Returns a map with all properties of this text format.
 
int propertyCount () const
 
void setObjectType (int type)
 Sets the text format's object type to type.
 
int objectType () const
 Returns the text format's object type.
 
bool isCharFormat () const
 Returns true if this text format is a CharFormat; otherwise returns false.
 
bool isBlockFormat () const
 Returns true if this text format is a BlockFormat; otherwise returns false.
 
bool isListFormat () const
 Returns true if this text format is a ListFormat; otherwise returns false.
 
bool isFrameFormat () const
 Returns true if this text format is a FrameFormat; otherwise returns false.
 
bool isImageFormat () const
 Returns true if this text format is an image format; otherwise returns false.
 
bool isTableFormat () const
 Returns true if this text format is a TableFormat; otherwise returns false.
 
bool isTableCellFormat () const
 
QTextBlockFormat toBlockFormat () const
 Returns this format as a block format.
 
QTextCharFormat toCharFormat () const
 Returns this format as a character format.
 
QTextListFormat toListFormat () const
 Returns this format as a list format.
 
QTextTableFormat toTableFormat () const
 Returns this format as a table format.
 
QTextFrameFormat toFrameFormat () const
 Returns this format as a frame format.
 
QTextImageFormat toImageFormat () const
 Returns this format as an image format.
 
QTextTableCellFormat toTableCellFormat () const
 
bool operator== (const QTextFormat &rhs) const
 Returns true if this text format is the same as the other text format.
 
bool operator!= (const QTextFormat &rhs) const
 Returns true if this text format is different from the other text format.
 
 operator QVariant () const
 Returns the text format as a QVariant.
 
void setLayoutDirection (Qt::LayoutDirection direction)
 Sets the document's layout direction to the specified direction.
 
Qt::LayoutDirection layoutDirection () const
 Returns the document's layout direction.
 
void setBackground (const QBrush &brush)
 Sets the brush use to paint the document's background to the brush specified.
 
QBrush background () const
 Returns the brush used to paint the document's background.
 
void clearBackground ()
 Clears the brush used to paint the document's background.
 
void setForeground (const QBrush &brush)
 Sets the foreground brush to the specified brush.
 
QBrush foreground () const
 Returns the brush used to render foreground details, such as text, frame outlines, and table borders.
 
void clearForeground ()
 Clears the brush used to paint the document's foreground.
 

Protected Member Functions

 QTextTableFormat (const QTextFormat &fmt)
 
- Protected Member Functions inherited from QTextFrameFormat
 QTextFrameFormat (const QTextFormat &fmt)
 

Friends

class QTextFormat
 

Additional Inherited Members

- Public Types inherited from QTextFrameFormat
enum  Position { InFlow , FloatLeft , FloatRight }
 This enum describes how a frame is located relative to the surrounding text. More...
 
enum  BorderStyle {
  BorderStyle_None , BorderStyle_Dotted , BorderStyle_Dashed , BorderStyle_Solid ,
  BorderStyle_Double , BorderStyle_DotDash , BorderStyle_DotDotDash , BorderStyle_Groove ,
  BorderStyle_Ridge , BorderStyle_Inset , BorderStyle_Outset
}
 
- Public Types inherited from QTextFormat
enum  FormatType {
  InvalidFormat = -1 , BlockFormat = 1 , CharFormat = 2 , ListFormat = 3 ,
  FrameFormat = 5 , UserFormat = 100
}
 This enum describes the text item a QTextFormat object is formatting. More...
 
enum  Property {
  ObjectIndex = 0x0 , CssFloat = 0x0800 , LayoutDirection = 0x0801 , OutlinePen = 0x810 ,
  BackgroundBrush = 0x820 , ForegroundBrush = 0x821 , BackgroundImageUrl = 0x823 , BlockAlignment = 0x1010 ,
  BlockTopMargin = 0x1030 , BlockBottomMargin = 0x1031 , BlockLeftMargin = 0x1032 , BlockRightMargin = 0x1033 ,
  TextIndent = 0x1034 , TabPositions = 0x1035 , BlockIndent = 0x1040 , LineHeight = 0x1048 ,
  LineHeightType = 0x1049 , BlockNonBreakableLines = 0x1050 , BlockTrailingHorizontalRulerWidth = 0x1060 , HeadingLevel = 0x1070 ,
  BlockQuoteLevel = 0x1080 , BlockCodeLanguage = 0x1090 , BlockCodeFence = 0x1091 , BlockMarker = 0x10A0 ,
  FirstFontProperty = 0x1FE0 , FontCapitalization = FirstFontProperty , FontLetterSpacing = 0x1FE1 , FontWordSpacing = 0x1FE2 ,
  FontStyleHint = 0x1FE3 , FontStyleStrategy = 0x1FE4 , FontKerning = 0x1FE5 , FontHintingPreference = 0x1FE6 ,
  FontFamilies = 0x1FE7 , FontStyleName = 0x1FE8 , FontLetterSpacingType = 0x1FE9 , FontStretch = 0x1FEA ,
  FontPointSize = 0x2001 , FontSizeAdjustment = 0x2002 , FontSizeIncrement = FontSizeAdjustment , FontWeight = 0x2003 ,
  FontItalic = 0x2004 , FontUnderline = 0x2005 , FontOverline = 0x2006 , FontStrikeOut = 0x2007 ,
  FontFixedPitch = 0x2008 , FontPixelSize = 0x2009 , LastFontProperty = FontPixelSize , TextUnderlineColor = 0x2020 ,
  TextVerticalAlignment = 0x2021 , TextOutline = 0x2022 , TextUnderlineStyle = 0x2023 , TextToolTip = 0x2024 ,
  TextSuperScriptBaseline = 0x2025 , TextSubScriptBaseline = 0x2026 , TextBaselineOffset = 0x2027 , IsAnchor = 0x2030 ,
  AnchorHref = 0x2031 , AnchorName = 0x2032 , OldFontLetterSpacingType = 0x2033 , OldFontStretch = 0x2034 ,
  OldTextUnderlineColor = 0x2010 , OldFontFamily = 0x2000 , ObjectType = 0x2f00 , ListStyle = 0x3000 ,
  ListIndent = 0x3001 , ListNumberPrefix = 0x3002 , ListNumberSuffix = 0x3003 , ListStart = 0x3004 ,
  FrameBorder = 0x4000 , FrameMargin = 0x4001 , FramePadding = 0x4002 , FrameWidth = 0x4003 ,
  FrameHeight = 0x4004 , FrameTopMargin = 0x4005 , FrameBottomMargin = 0x4006 , FrameLeftMargin = 0x4007 ,
  FrameRightMargin = 0x4008 , FrameBorderBrush = 0x4009 , FrameBorderStyle = 0x4010 , TableColumns = 0x4100 ,
  TableColumnWidthConstraints = 0x4101 , TableCellSpacing = 0x4102 , TableCellPadding = 0x4103 , TableHeaderRowCount = 0x4104 ,
  TableBorderCollapse = 0x4105 , TableCellRowSpan = 0x4810 , TableCellColumnSpan = 0x4811 , TableCellTopPadding = 0x4812 ,
  TableCellBottomPadding = 0x4813 , TableCellLeftPadding = 0x4814 , TableCellRightPadding = 0x4815 , TableCellTopBorder = 0x4816 ,
  TableCellBottomBorder = 0x4817 , TableCellLeftBorder = 0x4818 , TableCellRightBorder = 0x4819 , TableCellTopBorderStyle = 0x481a ,
  TableCellBottomBorderStyle = 0x481b , TableCellLeftBorderStyle = 0x481c , TableCellRightBorderStyle = 0x481d , TableCellTopBorderBrush = 0x481e ,
  TableCellBottomBorderBrush = 0x481f , TableCellLeftBorderBrush = 0x4820 , TableCellRightBorderBrush = 0x4821 , ImageName = 0x5000 ,
  ImageTitle = 0x5001 , ImageAltText = 0x5002 , ImageWidth = 0x5010 , ImageHeight = 0x5011 ,
  ImageQuality = 0x5014 , ImageMaxWidth = 0x5015 , FullWidthSelection = 0x06000 , PageBreakPolicy = 0x7000 ,
  UserProperty = 0x100000
}
 This enum describes the different properties a format can have. More...
 
enum  ObjectTypes {
  NoObject , ImageObject , TableObject , TableCellObject ,
  UserObject = 0x1000
}
 This enum describes what kind of QTextObject this format is associated with. More...
 
enum  PageBreakFlag { PageBreak_Auto = 0 , PageBreak_AlwaysBefore = 0x001 , PageBreak_AlwaysAfter = 0x010 }
 

Detailed Description

\reentrant

The QTextTableFormat class provides formatting information for tables in a QTextDocument. \inmodule QtGui

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().

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 list containing new constraints. If no constraints are required, clearColumnWidthConstraints() can be used to remove them.

See also
QTextTable, QTextTableCell, QTextLength

Definition at line 959 of file qtextformat.h.

Constructor & Destructor Documentation

◆ QTextTableFormat() [1/2]

QTextTableFormat::QTextTableFormat ( )

Constructs a new table format object.

Definition at line 3156 of file qtextformat.cpp.

References QTextFrameFormat::setBorder(), setBorderCollapse(), setCellPadding(), QTextFormat::setObjectType(), and QTextFormat::TableObject.

+ Here is the call graph for this function:

◆ QTextTableFormat() [2/2]

QTextTableFormat::QTextTableFormat ( const QTextFormat & other)
explicitprotected

Creates a new table format with the same attributes as the given text format.

Definition at line 3172 of file qtextformat.cpp.

Member Function Documentation

◆ alignment()

Qt::Alignment QTextTableFormat::alignment ( ) const
inline

Returns the table's alignment.

See also
setAlignment()

Definition at line 989 of file qtextformat.h.

◆ borderCollapse()

bool QTextTableFormat::borderCollapse ( ) const
inline
Since
5.14

Returns true if borderCollapse is enabled.

See also
setBorderCollapse()

Definition at line 999 of file qtextformat.h.

◆ cellPadding()

qreal QTextTableFormat::cellPadding ( ) const
inline

Returns the table's cell padding.

This describes the distance between the border of a cell and its contents.

Definition at line 984 of file qtextformat.h.

◆ cellSpacing()

qreal QTextTableFormat::cellSpacing ( ) const
inline

Returns the table's cell spacing.

This describes the distance between adjacent cells.

Definition at line 979 of file qtextformat.h.

◆ clearColumnWidthConstraints()

void QTextTableFormat::clearColumnWidthConstraints ( )
inline

Clears the column width constraints for the table.

See also
columnWidthConstraints(), setColumnWidthConstraints()

Definition at line 976 of file qtextformat.h.

Referenced by QTextCopyHelper::copy().

+ Here is the caller graph for this function:

◆ columns()

int QTextTableFormat::columns ( ) const
inline

Returns the number of columns specified by the table format.

Definition at line 966 of file qtextformat.h.

◆ columnWidthConstraints()

QList< QTextLength > QTextTableFormat::columnWidthConstraints ( ) const
inline

Returns a list of constraints used by this table format to control the appearance of columns in a table.

See also
setColumnWidthConstraints()

Definition at line 973 of file qtextformat.h.

◆ headerRowCount()

int QTextTableFormat::headerRowCount ( ) const
inline
Since
4.2

Returns the number of rows in the table that define the header.

See also
setHeaderRowCount()

Definition at line 994 of file qtextformat.h.

◆ isValid()

bool QTextTableFormat::isValid ( ) const
inline

Returns true if this table format is valid; otherwise returns false.

Definition at line 964 of file qtextformat.h.

◆ setAlignment()

void QTextTableFormat::setAlignment ( Qt::Alignment alignment)
inline

Sets the table's alignment.

See also
alignment()

Definition at line 1019 of file qtextformat.h.

References QTextFormat::BlockAlignment, and setProperty.

Referenced by main().

+ Here is the caller graph for this function:

◆ setBorderCollapse()

void QTextTableFormat::setBorderCollapse ( bool borderCollapse)
inline
Since
5.14

Enabling borderCollapse will have the following implications: \list

  • The borders and grid of the table will be rendered following the CSS table border-collapse: collapse rules
  • Setting the border property to a minimum value of 1 will render a one pixel solid inner table grid using the \l borderBrush property and an outer border as specified
  • The various border style properties of \l QTextTableCellFormat can be used to customize the grid and have precedence over the border and grid of the table
  • The \l cellSpacing property will be ignored
  • For print pagination: \list
  • Columns continued on a page will not have their top cell border rendered
  • Repeated header rows will always have their bottom cell border rendered \endlist \endlist

With borderCollapse disabled, cell borders can still be styled using QTextTableCellFormat but styling will be applied only within the cell's frame, which is probably not very useful in practice.

See also
setBorder(), setBorderBrush(), setBorderStyle()
QTextTableCellFormat

Definition at line 997 of file qtextformat.h.

References setProperty.

Referenced by QTextTableFormat().

+ Here is the caller graph for this function:

◆ setCellPadding()

void QTextTableFormat::setCellPadding ( qreal padding)
inline

Sets the cell padding for the table.

This determines the distance between the border of a cell and its contents.

Definition at line 1016 of file qtextformat.h.

References setProperty, and QTextFormat::TableCellPadding.

Referenced by QTextTableFormat(), and main().

+ Here is the caller graph for this function:

◆ setCellSpacing()

void QTextTableFormat::setCellSpacing ( qreal spacing)
inline

Sets the cell spacing for the table.

This determines the distance between adjacent cells.

This property will be ignored if \l borderCollapse is enabled.

Definition at line 981 of file qtextformat.h.

References setProperty, and spacing.

Referenced by main().

+ Here is the caller graph for this function:

◆ setColumns()

void QTextTableFormat::setColumns ( int columns)
inline

Sets the number of columns required by the table format.

See also
columns()

Definition at line 1009 of file qtextformat.h.

References setProperty, and QTextFormat::TableColumns.

Referenced by QTextCopyHelper::copy(), QTextTablePrivate::createTable(), and QTextTable::setFormat().

+ Here is the caller graph for this function:

◆ setColumnWidthConstraints()

void QTextTableFormat::setColumnWidthConstraints ( const QList< QTextLength > & constraints)
inline

Sets the column width constraints for the table.

See also
columnWidthConstraints(), clearColumnWidthConstraints()

Definition at line 970 of file qtextformat.h.

References setProperty.

◆ setHeaderRowCount()

void QTextTableFormat::setHeaderRowCount ( int count)
inline
Since
4.2

Declares the first count rows of the table as table header. The table header rows get repeated when a table is broken across a page boundary.

Definition at line 992 of file qtextformat.h.

References setProperty.

Friends And Related Symbol Documentation

◆ QTextFormat

friend class QTextFormat
friend

Definition at line 1004 of file qtextformat.h.


The documentation for this class was generated from the following files: