QTextTable Class

QTextTable 클래스는 QTextDocument...에 있는 테이블을 나타냅니다.. ..

헤더: #include <QTextTable>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
상속합니다: QTextFrame

참고: 이 클래스의 모든 함수는 재진입합니다.

공용 함수

void appendColumns(int count)
void appendRows(int count)
QTextTableCell cellAt(int row, int column) const
QTextTableCell cellAt(const QTextCursor &cursor) const
QTextTableCell cellAt(int position) const
int columns() const
QTextTableFormat format() const
void insertColumns(int index, int columns)
void insertRows(int index, int rows)
void mergeCells(int row, int column, int numRows, int numCols)
void mergeCells(const QTextCursor &cursor)
void removeColumns(int index, int columns)
void removeRows(int index, int rows)
void resize(int rows, int columns)
QTextCursor rowEnd(const QTextCursor &cursor) const
QTextCursor rowStart(const QTextCursor &cursor) const
int rows() const
void setFormat(const QTextTableFormat &format)
void splitCell(int row, int column, int numRows, int numCols)

상세 설명

표는 행과 열로 정렬된 셀 그룹입니다. 각 테이블은 적어도 하나의 행과 하나의 열을 포함합니다. 각 셀은 블록을 포함하며 프레임으로 둘러싸여 있습니다.

표는 일반적으로 QTextCursor::insertTable() 함수를 사용하여 문서에 생성하고 삽입합니다. 예를 들어 편집기에서 다음 코드 줄을 사용하여 현재 커서 위치에 3개의 행과 2개의 열이 있는 표를 삽입할 수 있습니다:

    QTextCursor cursor(editor->textCursor());
    cursor.movePosition(QTextCursor::Start);

    QTextTable *table = cursor.insertTable(rows, columns, tableFormat);

표 형식은 표를 만들 때 정의하거나 나중에 setFormat()를 사용하여 변경합니다.

현재 커서가 편집 중인 표는 QTextCursor::currentTable()로 찾을 수 있습니다. 이렇게 하면 문서에 삽입한 후에 표의 형식이나 크기를 변경할 수 있습니다.

표의 크기는 resize() 또는 insertRows(), insertColumns(), removeRows() 또는 removeColumns()를 사용하여 변경할 수 있습니다. 표 셀을 검색하려면 cellAt()를 사용합니다.

표 행의 시작 및 끝 위치는 표 내에서 커서를 이동하고 rowStart() 및 rowEnd() 함수를 사용하여 각 행의 시작과 끝에서 커서를 가져와서 찾을 수 있습니다.

mergeCells() 및 splitCell() 함수를 사용하여 QTextTable 내의 행과 열을 병합 및 분할할 수 있습니다. 그러나 여러 행 또는 열에 걸쳐 있는 셀만 분할할 수 있습니다. (병합 또는 분할해도 행과 열의 수는 증가하거나 감소하지 않습니다.)

여러 개의 열과 행을 하나의 셀로 병합한 경우 병합된 셀을 둘 이상의 행 또는 열에 걸쳐 있는 새 셀로 분할할 수 없다는 점에 유의하세요. 여러 행과 열에 걸쳐 있는 셀을 분할하려면 여러 번의 반복을 통해 분할해야 합니다.

원본 표이름과 주소로 구성된 2x3 테이블이 있다고 가정해 보겠습니다. 첫 번째 행의 두 열을 병합하려면 row = 0, column = 0, numRows = 1, numColumns = 2로 mergeCells()를 호출합니다.
    table->mergeCells(0, 0, 1, 2);
그러면 다음과 같은 테이블이 생성됩니다. 테이블의 첫 번째 행을 다시 두 개의 셀로 분할하려면 numRowsnumCols = 1을 사용하여 splitCell() 함수를 호출합니다.
    table->splitCell(0, 0, 1, 1);
테이블 분할그러면 원래 테이블이 생성됩니다.

QTextTableFormat참조하세요 .

멤버 함수 문서

void QTextTable::appendColumns(int count)

표의 오른쪽에 count 열을 추가합니다.

insertColumns(), insertRows(), resize(), removeRows(), removeColumns() 및 appendRows()도 참조하세요 .

void QTextTable::appendRows(int count)

표 하단에 count 행을 추가합니다.

insertColumns(), insertRows(), resize(), removeRows(), removeColumns() 및 appendColumns()도 참조하세요 .

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

테이블의 지정된 rowcolumn 에 있는 테이블 셀을 반환합니다.

columns() 및 rows()도 참조하세요 .

QTextTableCell QTextTable::cellAt(const QTextCursor &cursor) const

이 함수는 오버로드된 함수입니다.

주어진 cursor 을 포함하는 테이블 셀을 반환합니다.

QTextTableCell QTextTable::cellAt(int position) const

이 함수는 오버로드된 함수입니다.

문서에서 지정된 position 위치에 있는 문자가 포함된 테이블 셀을 반환합니다.

int QTextTable::columns() const

테이블의 열 수를 반환합니다.

rows()도 참조하세요 .

QTextTableFormat QTextTable::format() const

테이블의 형식을 반환합니다.

setFormat()도 참조하세요 .

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

지정된 index 이 있는 열 앞에 columns 을 삽입합니다.

insertRows(), resize(), removeRows(), removeColumns(), appendRows() 및 appendColumns()도 참조하세요 .

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

지정된 index 이 있는 행 앞에 rows 을 삽입합니다.

resize(), insertColumns(), removeRows(), removeColumns(), appendRows() 및 appendColumns()도 참조하세요 .

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

지정된 rowcolumn 의 셀을 인접한 셀과 하나의 셀로 병합합니다. 새 셀은 numRows 행과 numCols 열에 걸쳐 있습니다. numRows 또는 numCols 이 셀에 포함된 현재 행 또는 열 수보다 작으면 이 메서드는 아무 작업도 수행하지 않습니다.

splitCell()도 참조하세요 .

void QTextTable::mergeCells(const QTextCursor &cursor)

과부하가 걸린 함수입니다.

제공된 cursor 에 의해 선택된 셀을 병합합니다.

splitCell()도 참조하세요 .

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

지정된 index 에서 열로 시작하는 columns 을 제거합니다.

insertRows(), insertColumns(), removeRows(), resize(), appendRows() 및 appendColumns()도 참조하세요 .

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

지정된 index 에서 행으로 시작하는 rows 을 제거합니다.

insertRows(), insertColumns(), resize(), removeColumns(), appendRows() 및 appendColumns()도 참조하세요 .

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

필요한 수의 rowscolumns 을 포함하도록 테이블의 크기를 조정합니다.

insertRows(), insertColumns(), removeRows() 및 removeColumns()도 참조하세요 .

QTextCursor QTextTable::rowEnd(const QTextCursor &cursor) const

주어진 cursor 이 포함된 행의 끝을 가리키는 커서를 반환합니다.

rowStart()도 참조하세요 .

QTextCursor QTextTable::rowStart(const QTextCursor &cursor) const

주어진 cursor 이 포함된 행의 시작 부분을 가리키는 커서를 반환합니다.

rowEnd()도 참조하세요 .

int QTextTable::rows() const

테이블의 행 수를 반환합니다.

columns()도 참조하세요 .

void QTextTable::setFormat(const QTextTableFormat &format)

테이블의 format 을 설정합니다.

format()도 참조하세요 .

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

rowcolumn 에서 지정한 셀을 numRowsnumCols 에서 지정한 치수의 여러 셀 배열로 분할합니다.

참고: mergeCells()를 사용하여 병합된 행과 같이 여러 행 또는 열에 걸쳐 있는 셀만 분할할 수 있습니다.

mergeCells()도 참조하세요 .

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.