QtBase  v6.3.1
Public Member Functions | Friends | List of all members
QTextTable Class Reference

The QTextTable class represents a table in a QTextDocument. \inmodule QtGui. More...

#include <qtexttable.h>

Inheritance diagram for QTextTable:
Inheritance graph
[legend]
Collaboration diagram for QTextTable:
Collaboration graph
[legend]

Public Member Functions

 QTextTable (QTextDocument *doc)
 
 ~QTextTable ()
 
void resize (int rows, int cols)
 
void insertRows (int pos, int num)
 
void insertColumns (int pos, int num)
 
void appendRows (int count)
 
void appendColumns (int count)
 
void removeRows (int pos, int num)
 
void removeColumns (int pos, int num)
 
void mergeCells (int row, int col, int numRows, int numCols)
 
void mergeCells (const QTextCursor &cursor)
 
void splitCell (int row, int col, int numRows, int numCols)
 
int rows () const
 
int columns () const
 
QTextTableCell cellAt (int row, int col) const
 
QTextTableCell cellAt (int position) const
 
QTextTableCell cellAt (const QTextCursor &c) const
 
QTextCursor rowStart (const QTextCursor &c) const
 
QTextCursor rowEnd (const QTextCursor &c) const
 
void setFormat (const QTextTableFormat &format)
 
QTextTableFormat format () const
 
- Public Member Functions inherited from QTextFrame
 QTextFrame (QTextDocument *doc)
 
 ~QTextFrame ()
 
void setFrameFormat (const QTextFrameFormat &format)
 
QTextFrameFormat frameFormat () const
 
QTextCursor firstCursorPosition () const
 
QTextCursor lastCursorPosition () const
 
int firstPosition () const
 
int lastPosition () const
 
QTextFrameLayoutDatalayoutData () const
 
void setLayoutData (QTextFrameLayoutData *data)
 
QList< QTextFrame * > childFrames () const
 
QTextFrameparentFrame () const
 
iterator begin () const
 
iterator end () const
 
- Public Member Functions inherited from QTextObject
QTextFormat format () const
 
int formatIndex () const
 
QTextDocumentdocument () const
 
int objectIndex () const
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 
virtual ~QObject ()
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const
 
void setObjectName (const QString &name)
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const noexcept
 
bool blockSignals (bool b) noexcept
 
QThreadthread () const
 
void moveToThread (QThread *thread)
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 
template<typename T >
T findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
const QObjectListchildren () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 
void dumpObjectInfo () const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 
bool inherits (const char *classname) const
 

Friends

class QTextTableCell
 

Additional Inherited Members

- Public Types inherited from QTextFrame
typedef iterator Iterator
 
- Public Slots inherited from QObject
void deleteLater ()
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Member Functions inherited from QTextFrame
 QTextFrame (QTextFramePrivate &p, QTextDocument *doc)
 
- Protected Member Functions inherited from QTextObject
 QTextObject (QTextDocument *doc)
 
 ~QTextObject ()
 
void setFormat (const QTextFormat &format)
 
 QTextObject (QTextObjectPrivate &p, QTextDocument *doc)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Properties inherited from QObject
QString objectName
 the name of this object More...
 

Detailed Description

The QTextTable class represents a table in a QTextDocument. \inmodule QtGui.

\reentrant

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, and is surrounded by a frame.

Tables are usually created and inserted into a document with the QTextCursor::insertTable() function. For example, we can insert a table with three rows and two columns at the current cursor position in an editor using the following lines of code:

\codeline

The table format is either defined when the table is created or changed later with setFormat().

The table currently being edited by the cursor is found with QTextCursor::currentTable(). This allows its format or dimensions to be changed after it has been inserted into a document.

A table's size can be changed with resize(), or by using insertRows(), insertColumns(), removeRows(), or removeColumns(). Use cellAt() to retrieve table cells.

The starting and ending positions of table rows can be found by moving a cursor within a table, and using the rowStart() and rowEnd() functions to obtain cursors at the start and end of each row.

Rows and columns within a QTextTable can be merged and split using the mergeCells() and splitCell() functions. However, only cells that span multiple rows or columns can be split. (Merging or splitting does not increase or decrease the number of rows and columns.)

Note that if you have merged multiple columns and rows into one cell, you will not be able to split the merged cell into new cells spanning over more than one row or column. To be able to split cells spanning over several rows and columns you need to do this over several iterations.

\table 80% \row

See also
QTextTableFormat

Definition at line 98 of file qtexttable.h.

Constructor & Destructor Documentation

◆ QTextTable()

QTextTable::QTextTable ( QTextDocument doc)
explicit

Definition at line 559 of file qtexttable.cpp.

◆ ~QTextTable()

QTextTable::~QTextTable ( )

Definition at line 568 of file qtexttable.cpp.

Member Function Documentation

◆ appendColumns()

void QTextTable::appendColumns ( int  count)
Since
4.5 Appends count columns at the right side of the table.
See also
insertColumns(), insertRows(), resize(), removeRows(), removeColumns(), appendRows()

Definition at line 848 of file qtexttable.cpp.

Here is the call graph for this function:

◆ appendRows()

void QTextTable::appendRows ( int  count)
Since
4.5 Appends count rows at the bottom of the table.
See also
insertColumns(), insertRows(), resize(), removeRows(), removeColumns(), appendColumns()

Definition at line 837 of file qtexttable.cpp.

Here is the call graph for this function:

◆ cellAt() [1/3]

QTextTableCell QTextTable::cellAt ( const QTextCursor cursor) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns the table cell containing the given cursor.

Definition at line 624 of file qtexttable.cpp.

Here is the call graph for this function:

◆ cellAt() [2/3]

QTextTableCell QTextTable::cellAt ( int  position) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns the table cell that contains the character at the given position in the document.

Definition at line 598 of file qtexttable.cpp.

Here is the call graph for this function:

◆ cellAt() [3/3]

QTextTableCell QTextTable::cellAt ( int  row,
int  column 
) const

Returns the table cell at the given row and column in the table.

See also
columns(), rows()

Definition at line 580 of file qtexttable.cpp.

Here is the caller graph for this function:

◆ columns()

int QTextTable::columns ( ) const

Returns the number of columns in the table.

See also
rows()

Definition at line 1262 of file qtexttable.cpp.

Here is the caller graph for this function:

◆ format()

QTextTableFormat QTextTable::format ( ) const
inline

Returns the table's format.

See also
setFormat()

Definition at line 128 of file qtexttable.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertColumns()

void QTextTable::insertColumns ( int  index,
int  columns 
)

Inserts a number of columns before the column with the specified index.

See also
insertRows(), resize(), removeRows(), removeColumns(), appendRows(), appendColumns()

Definition at line 736 of file qtexttable.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertRows()

void QTextTable::insertRows ( int  index,
int  rows 
)

Inserts a number of rows before the row with the specified index.

See also
resize(), insertColumns(), removeRows(), removeColumns(), appendRows(), appendColumns()

Definition at line 670 of file qtexttable.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mergeCells() [1/2]

void QTextTable::mergeCells ( const QTextCursor cursor)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
4.1

Merges the cells selected by the provided cursor.

See also
splitCell()

Definition at line 1156 of file qtexttable.cpp.

Here is the call graph for this function:

◆ mergeCells() [2/2]

void QTextTable::mergeCells ( int  row,
int  column,
int  numRows,
int  numCols 
)
Since
4.1

Merges the cell at the specified row and column with the adjacent cells into one cell. The new cell will span numRows rows and numCols columns. This method does nothing if numRows or numCols is less than the current number of rows or columns spanned by the cell.

See also
splitCell()

Definition at line 996 of file qtexttable.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeColumns()

void QTextTable::removeColumns ( int  index,
int  columns 
)

Removes a number of columns starting with the column at the specified index.

See also
insertRows(), insertColumns(), removeRows(), resize(), appendRows(), appendColumns()

Definition at line 922 of file qtexttable.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeRows()

void QTextTable::removeRows ( int  index,
int  rows 
)

Removes a number of rows starting with the row at the specified index.

See also
insertRows(), insertColumns(), resize(), removeColumns(), appendRows(), appendColumns()

Definition at line 860 of file qtexttable.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize()

void QTextTable::resize ( int  rows,
int  columns 
)

Resizes the table to contain the required number of rows and columns.

See also
insertRows(), insertColumns(), removeRows(), removeColumns()

Definition at line 636 of file qtexttable.cpp.

Here is the call graph for this function:

◆ rowEnd()

QTextCursor QTextTable::rowEnd ( const QTextCursor cursor) const

Returns a cursor pointing to the end of the row that contains the given cursor.

See also
rowStart()

Definition at line 1300 of file qtexttable.cpp.

Here is the call graph for this function:

◆ rows()

int QTextTable::rows ( ) const

Returns the number of rows in the table.

See also
columns()

Definition at line 1248 of file qtexttable.cpp.

Here is the caller graph for this function:

◆ rowStart()

QTextCursor QTextTable::rowStart ( const QTextCursor cursor) const

Returns a cursor pointing to the start of the row that contains the given cursor.

See also
rowEnd()

Definition at line 1279 of file qtexttable.cpp.

Here is the call graph for this function:

◆ setFormat()

void QTextTable::setFormat ( const QTextTableFormat format)

Sets the table's format.

See also
format()

Definition at line 1321 of file qtexttable.cpp.

Here is the call graph for this function:

◆ splitCell()

void QTextTable::splitCell ( int  row,
int  column,
int  numRows,
int  numCols 
)
Since
4.1

Splits the specified cell at row and column into an array of multiple cells with dimensions specified by numRows and numCols.

Note
It is only possible to split cells that span multiple rows or columns, such as rows that have been merged using mergeCells().
See also
mergeCells()

Definition at line 1177 of file qtexttable.cpp.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ QTextTableCell

friend class QTextTableCell
friend

Definition at line 133 of file qtexttable.h.


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