void ChatAreaWidget::insertMessage(ChatAction *msgAction) { if (msgAction == nullptr) return; checkSlider(); QTextTable *chatTextTable = getMsgTable(); QTextCursor cur = chatTextTable->cellAt(0, 2).firstCursorPosition(); cur.clearSelection(); cur.setKeepPositionOnInsert(true); chatTextTable->cellAt(0, 0).firstCursorPosition().setBlockFormat(nameFormat); chatTextTable->cellAt(0, 0).firstCursorPosition().insertHtml(msgAction->getName()); chatTextTable->cellAt(0, 2).firstCursorPosition().insertHtml(msgAction->getMessage()); chatTextTable->cellAt(0, 4).firstCursorPosition().setBlockFormat(dateFormat); chatTextTable->cellAt(0, 4).firstCursorPosition().insertHtml(msgAction->getDate()); msgAction->setup(cur, this); messages.append(msgAction); }