I created QTextTable:

Qt Code:
  1. QTextDocument *document=new QTextDocument(this);
  2. QTextCursor cursor(document);
  3. cursor.movePosition(QTextCursor::Start);
  4.  
  5. QTextTableCellFormat cellFormat;
  6. cellFormat.setLeftPadding(7);
  7. cellFormat.setRightPadding(7);
  8.  
  9. QBrush blackBrush(Qt::SolidPattern);
  10. QTextTableFormat tableFormat;
  11. tableFormat.setAlignment(Qt::AlignCenter);
  12. tableFormat.setBorderBrush(blackBrush);
  13. tableFormat.setBorder(0.5);
  14. tableFormat.setCellSpacing(0);
  15. tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
  16. tableFormat.setWidth(QTextLength(QTextLength::PercentageLength, 100));
  17. QTextTable *table = cursor.insertTable(10,10,tableFormat);
  18.  
  19. QTextBlockFormat centerAlignment;
  20. centerAlignment.setAlignment(Qt::AlignCenter);
  21.  
  22. table->mergeCells(0,0,10,5);
  23. cursor = table->cellAt(0, 0).firstCursorPosition();
  24. cursor.setBlockFormat(centerAlignment);
  25. 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.