I created QTextTable:
QTextTableCellFormat cellFormat;
cellFormat.setLeftPadding(7);
cellFormat.setRightPadding(7);
QBrush blackBrush
(Qt
::SolidPattern);
tableFormat.setAlignment(Qt::AlignCenter);
tableFormat.setBorderBrush(blackBrush);
tableFormat.setBorder(0.5);
tableFormat.setCellSpacing(0);
QTextTable *table
= cursor.
insertTable(10,
10,tableFormat
);
centerAlignment.setAlignment(Qt::AlignCenter);
table->mergeCells(0,0,10,5);
cursor = table->cellAt(0, 0).firstCursorPosition();
cursor.setBlockFormat(centerAlignment);
cursor.insertText("text");
QTextDocument *document=new QTextDocument(this);
QTextCursor cursor(document);
cursor.movePosition(QTextCursor::Start);
QTextTableCellFormat cellFormat;
cellFormat.setLeftPadding(7);
cellFormat.setRightPadding(7);
QBrush blackBrush(Qt::SolidPattern);
QTextTableFormat tableFormat;
tableFormat.setAlignment(Qt::AlignCenter);
tableFormat.setBorderBrush(blackBrush);
tableFormat.setBorder(0.5);
tableFormat.setCellSpacing(0);
tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
tableFormat.setWidth(QTextLength(QTextLength::PercentageLength, 100));
QTextTable *table = cursor.insertTable(10,10,tableFormat);
QTextBlockFormat centerAlignment;
centerAlignment.setAlignment(Qt::AlignCenter);
table->mergeCells(0,0,10,5);
cursor = table->cellAt(0, 0).firstCursorPosition();
cursor.setBlockFormat(centerAlignment);
cursor.insertText("text");
To copy to clipboard, switch view to plain text mode
I want to write text in the middle of cell vertically and horizontally
But my text is in the middle horizontally but it is not in the middle vertically.
Also Qt::AlignVCenter and Qt::AlignBottom do not work.
Bookmarks