Помощь - Поиск - Пользователи - Календарь
Полная версия этой страницы: QTextTable Разбиение столбца на 2
Форум на CrossPlatform.RU > Библиотеки > Qt > Qt GUI
bynet
Привет всем! Интересует разбиение столбца на столбцы. По вики вычетал splitCell() но как его использовать незнаю. Приведите пример

Таблица к пример:
---------------------------------
1------| 2 | 3 | 4 |
---------------------------------
1.1|1.2 | 2.1 | 3.1 | 4.1 |
---------------------------------
Вот так я создаю таблицу

QTextCursor cursor(editor->textCursor());
cursor.movePosition(QTextCursor::Start);
QTextTable *table = cursor.insertTable(2, 3, tableFormat);
cursor = table->cellAt(0, 0).firstCursorPosition();
cursor.insertText(tr("1"), textFormat);
cursor = table->cellAt(0, 1).firstCursorPosition();
cursor.insertText(tr("2"), boldFormat);
cursor = table->cellAt(0, 2).firstCursorPosition();
cursor.insertText(tr("3"), textFormat);
cursor = orderTable->cellAt(0, 3).firstCursorPosition();
cursor.insertText(tr("4"), boldFormat);


Как мне расбить колонку 1 на 1.1. 1.2 на следующей строчке?
igor_bogomolov
Так?

Раскрывающийся текст
    QTextTableFormat tableFormat;
    tableFormat.setBorder(1);
    tableFormat.setCellPadding(16);
    tableFormat.setAlignment(Qt::AlignCenter);
    
    QTextCharFormat textFormat;
    
    QTextCursor cursor(textEdit->textCursor());
    cursor.movePosition(QTextCursor::Start);
    
    QTextTable *table = cursor.insertTable(2, 5, tableFormat);
    table->mergeCells(0, 0, 1, 2);
    table->splitCell(0, 0, 1, 2);
    
    cursor = table->cellAt(0, 0).firstCursorPosition();
    cursor.insertText(tr("1"), textFormat);
    cursor = table->cellAt(0, 2).firstCursorPosition();
    cursor.insertText(tr("2"), textFormat);
    cursor = table->cellAt(0, 3).firstCursorPosition();
    cursor.insertText(tr("3"), textFormat);
    cursor = table->cellAt(0, 4).firstCursorPosition();
    cursor.insertText(tr("4"), textFormat);

    cursor = table->cellAt(1, 0).firstCursorPosition();
    cursor.insertText(tr("1.1"), textFormat);
    cursor = table->cellAt(1, 1).firstCursorPosition();
    cursor.insertText(tr("1.2"), textFormat);
    cursor = table->cellAt(1, 2).firstCursorPosition();
    cursor.insertText(tr("2"), textFormat);
    cursor = table->cellAt(1, 3).firstCursorPosition();
    cursor.insertText(tr("3"), textFormat);
    cursor = table->cellAt(1, 4).firstCursorPosition();
    cursor.insertText(tr("4"), textFormat);

bynet
да, спасибо
Для просмотра полной версии этой страницы, пожалуйста, пройдите по ссылке.
Форум IP.Board © 2001-2024 IPS, Inc.