CopperSpice API
1.9.2
|
The QTextTable class represents a table in a QTextDocument. More...
Public Methods | |
void | appendColumns (int count) |
void | appendRows (int count) |
QTextTableCell | cellAt (const QTextCursor &cursor) const |
QTextTableCell | cellAt (int position) const |
QTextTableCell | cellAt (int row, int column) const |
int | columns () const |
QTextTableFormat | format () const |
void | insertColumns (int index, int numColumns) |
void | insertRows (int index, int numRows) |
void | mergeCells (const QTextCursor &cursor) |
void | mergeCells (int row, int column, int numRows, int numColumns) |
void | removeColumns (int index, int numColumns) |
void | removeRows (int index, int numRows) |
void | resize (int rows, int columns) |
QTextCursor | rowEnd (const QTextCursor &cursor) const |
int | rows () const |
QTextCursor | rowStart (const QTextCursor &cursor) const |
void | setFormat (const QTextTableFormat &format) |
void | splitCell (int row, int column, int numRows, int numColumns) |
Public Methods inherited from QTextFrame | |
QTextFrame (QTextDocument *document) | |
~QTextFrame () | |
iterator | begin () const |
QList< QTextFrame * > | childFrames () const |
iterator | end () const |
QTextCursor | firstCursorPosition () const |
int | firstPosition () const |
QTextFrameFormat | frameFormat () const |
QTextCursor | lastCursorPosition () const |
int | lastPosition () const |
QTextFrame * | parentFrame () const |
void | setFrameFormat (const QTextFrameFormat &format) |
Public Methods inherited from QTextObject | |
QTextDocument * | document () const |
QTextFormat | format () const |
int | formatIndex () const |
int | objectIndex () const |
Public Methods inherited from QObject | |
QObject (QObject *parent=nullptr) | |
~QObject () | |
bool | blockSignals (bool block) |
const QList< QObject * > & | children () const |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QString > | dynamicPropertyNames () const |
virtual bool | event (QEvent *event) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
template<class T > | |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
bool | inherits (const QString &className) const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const |
bool | isWindowType () const |
void | killTimer (int id) |
const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | property (const QString &name) const |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const QString &name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
QThread * | thread () const |
Friends | |
class | QTextTableCell |
Additional Inherited Members | |
Public Signals inherited from QObject | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Slots inherited from QObject | |
void | deleteLater () |
Static Public Methods inherited from QObject | |
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
static QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
Protected Methods inherited from QTextObject | |
QTextObject (QTextDocument *document) | |
~QTextObject () | |
void | setFormat (const QTextFormat &format) |
Protected Methods inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Properties inherited from QObject | |
objectName | |
Related Functions inherited from QObject | |
T | qobject_cast (QObject *object) |
QObjectList | |
The QTextTable class represents a table in a QTextDocument.
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:
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.
Suppose we have a 2x3 table of names and addresses. To merge both columns in the first row we invoke mergeCells() with row = 0, column = 0, numRows = 1 and numColumns = 2. table->mergeCells(0, 0, 1, 2);
| |
This gives us the following table. To split the first row of the table back into two cells, we invoke the splitCell() function with numRows and numColumns = 1. table->splitCell(0, 0, 1, 1);
| |
This results in the original table. |
void QTextTable::appendColumns | ( | int | count | ) |
Appends count columns at the right side of the table.
void QTextTable::appendRows | ( | int | count | ) |
Appends count rows at the bottom of the table.
QTextTableCell QTextTable::cellAt | ( | const QTextCursor & | cursor | ) | const |
Returns the table cell containing the given cursor.
QTextTableCell QTextTable::cellAt | ( | int | position | ) | const |
Returns the table cell that contains the character at the given position in the document.
QTextTableCell QTextTable::cellAt | ( | int | row, |
int | column | ||
) | const |
int QTextTable::columns | ( | ) | const |
Returns the number of columns in the table.
|
inline |
Returns the table's format.
void QTextTable::insertColumns | ( | int | index, |
int | numColumns | ||
) |
Inserts a number of numColumns before the column with the specified index.
void QTextTable::insertRows | ( | int | index, |
int | numRows | ||
) |
Inserts a number of numRows before the row with the specified index.
void QTextTable::mergeCells | ( | const QTextCursor & | cursor | ) |
Merges the cells selected by the provided cursor.
void QTextTable::mergeCells | ( | int | row, |
int | column, | ||
int | numRows, | ||
int | numColumns | ||
) |
Merges the cell at the specified row and column with the adjacent cells into one cell. The new cell will span numRows and numColumns. If numRows or numColumns is less than the current number of rows or columns the cell spans then this method does nothing.
void QTextTable::removeColumns | ( | int | index, |
int | numColumns | ||
) |
Removes a number of numColumns starting with the column at the specified index.
void QTextTable::removeRows | ( | int | index, |
int | numRows | ||
) |
Removes a number of numRows starting with the row at the specified index.
void QTextTable::resize | ( | int | rows, |
int | columns | ||
) |
Resizes the table to contain the required number of rows and columns.
QTextCursor QTextTable::rowEnd | ( | const QTextCursor & | cursor | ) | const |
Returns a cursor pointing to the end of the row that contains the given cursor.
int QTextTable::rows | ( | ) | const |
Returns the number of rows in the table.
QTextCursor QTextTable::rowStart | ( | const QTextCursor & | cursor | ) | const |
Returns a cursor pointing to the start of the row that contains the given cursor.
void QTextTable::setFormat | ( | const QTextTableFormat & | format | ) |
Sets the table's format.
void QTextTable::splitCell | ( | int | row, |
int | column, | ||
int | numRows, | ||
int | numColumns | ||
) |
Splits the specified cell at row and column into an array of multiple cells with dimensions specified by numRows and numColumns.