Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QTextTableCell Class Reference

\reentrant More...

#include <qtexttable.h>

Collaboration diagram for QTextTableCell:

Public Member Functions

 QTextTableCell ()
 Constructs an invalid table cell.
 ~QTextTableCell ()
 Destroys the table cell.
 QTextTableCell (const QTextTableCell &o)
 Copy constructor.
QTextTableCelloperator= (const QTextTableCell &o)
 Assigns the other table cell to this table cell.
void setFormat (const QTextCharFormat &format)
QTextCharFormat format () const
 Returns the cell's character format.
int row () const
 Returns the number of the row in the table that contains this cell.
int column () const
 Returns the number of the column in the table that contains this cell.
int rowSpan () const
 Returns the number of rows this cell spans.
int columnSpan () const
 Returns the number of columns this cell spans.
bool isValid () const
 Returns true if this is a valid table cell; otherwise returns false.
QTextCursor firstCursorPosition () const
 Returns the first valid cursor position in this cell.
QTextCursor lastCursorPosition () const
 Returns the last valid cursor position in this cell.
int firstPosition () const
int lastPosition () const
bool operator== (const QTextTableCell &other) const
 Returns true if this cell object and the other cell object describe the same cell; otherwise returns false.
bool operator!= (const QTextTableCell &other) const
 Returns true if this cell object and the other cell object describe different cells; otherwise returns false.
QTextFrame::iterator begin () const
 Returns a frame iterator pointing to the beginning of the table's cell.
QTextFrame::iterator end () const
 Returns a frame iterator pointing to the end of the table's cell.
int tableCellFormatIndex () const

Friends

class QTextTable

Detailed Description

\reentrant

The QTextTableCell class represents the properties of a cell in a QTextTable. \inmodule QtGui

Table cells are pieces of document structure that belong to a table. The table orders cells into particular rows and columns; cells can also span multiple columns and rows.

Cells are usually created when a table is inserted into a document with QTextCursor::insertTable(), but they are also created and destroyed when a table is resized.

Cells contain information about their location in a table; you can obtain the row() and column() numbers of a cell, and its rowSpan() and columnSpan().

The format() of a cell describes the default character format of its contents. The firstCursorPosition() and lastCursorPosition() functions are used to obtain the extent of the cell in the document.

See also
QTextTable, QTextTableFormat

Definition at line 18 of file qtexttable.h.

Constructor & Destructor Documentation

◆ QTextTableCell() [1/2]

QTextTableCell::QTextTableCell ( )
inline

Constructs an invalid table cell.

See also
isValid()

Definition at line 21 of file qtexttable.h.

◆ ~QTextTableCell()

QTextTableCell::~QTextTableCell ( )
inline

Destroys the table cell.

Definition at line 22 of file qtexttable.h.

◆ QTextTableCell() [2/2]

QTextTableCell::QTextTableCell ( const QTextTableCell & other)
inline

Copy constructor.

Creates a new QTextTableCell object based on the other cell.

Definition at line 23 of file qtexttable.h.

Member Function Documentation

◆ begin()

QTextFrame::iterator QTextTableCell::begin ( ) const

Returns a frame iterator pointing to the beginning of the table's cell.

See also
end()

Definition at line 247 of file qtexttable.cpp.

◆ column()

int QTextTableCell::column ( ) const

Returns the number of the column in the table that contains this cell.

See also
row()

Definition at line 151 of file qtexttable.cpp.

◆ columnSpan()

int QTextTableCell::columnSpan ( ) const

Returns the number of columns this cell spans.

The default is 1.

See also
rowSpan()

Definition at line 178 of file qtexttable.cpp.

◆ end()

QTextFrame::iterator QTextTableCell::end ( ) const

Returns a frame iterator pointing to the end of the table's cell.

See also
begin()

Definition at line 260 of file qtexttable.cpp.

◆ firstCursorPosition()

QTextCursor QTextTableCell::firstCursorPosition ( ) const

Returns the first valid cursor position in this cell.

See also
lastCursorPosition()

Definition at line 196 of file qtexttable.cpp.

◆ firstPosition()

int QTextTableCell::firstPosition ( ) const

Returns the first valid position in the document occupied by this cell.

Definition at line 217 of file qtexttable.cpp.

◆ format()

QTextCharFormat QTextTableCell::format ( ) const

Returns the cell's character format.

Definition at line 106 of file qtexttable.cpp.

◆ isValid()

bool QTextTableCell::isValid ( ) const
inline

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

Definition at line 36 of file qtexttable.h.

◆ lastCursorPosition()

QTextCursor QTextTableCell::lastCursorPosition ( ) const

Returns the last valid cursor position in this cell.

See also
firstCursorPosition()

Definition at line 206 of file qtexttable.cpp.

◆ lastPosition()

int QTextTableCell::lastPosition ( ) const

Returns the last valid position in the document occupied by this cell.

Definition at line 228 of file qtexttable.cpp.

◆ operator!=()

bool QTextTableCell::operator!= ( const QTextTableCell & other) const
inline

Returns true if this cell object and the other cell object describe different cells; otherwise returns false.

Definition at line 45 of file qtexttable.h.

◆ operator=()

QTextTableCell & QTextTableCell::operator= ( const QTextTableCell & o)
inline

Assigns the other table cell to this table cell.

Definition at line 24 of file qtexttable.h.

◆ operator==()

bool QTextTableCell::operator== ( const QTextTableCell & other) const
inline

Returns true if this cell object and the other cell object describe the same cell; otherwise returns false.

Definition at line 43 of file qtexttable.h.

◆ row()

int QTextTableCell::row ( ) const

Returns the number of the row in the table that contains this cell.

See also
column()

Definition at line 134 of file qtexttable.cpp.

◆ rowSpan()

int QTextTableCell::rowSpan ( ) const

Returns the number of rows this cell spans.

The default is 1.

See also
columnSpan()

Definition at line 168 of file qtexttable.cpp.

◆ setFormat()

void QTextTableCell::setFormat ( const QTextCharFormat & format)
Since
4.2

Sets the cell's character format to format. This can for example be used to change the background color of the entire cell:

QTextTableCell cell = table->cellAt(2, 3);
format.setBackground(Qt::blue);
QTextCharFormat format() const
Returns the cell's character format.
void setFormat(const QTextCharFormat &format)
QTextTableCell()
Constructs an invalid table cell.
Definition qtexttable.h:21
@ blue
Definition qnamespace.h:38

Note that the cell's row or column span cannot be changed through this function. You have to use QTextTable::mergeCells and QTextTable::splitCell instead.

See also
format()

Definition at line 87 of file qtexttable.cpp.

◆ tableCellFormatIndex()

int QTextTableCell::tableCellFormatIndex ( ) const
Since
4.5

Returns the index of the tableCell's format in the document's internal list of formats.

See also
QTextDocument::allFormats()

Definition at line 123 of file qtexttable.cpp.

◆ QTextTable

friend class QTextTable
friend

Definition at line 54 of file qtexttable.h.


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