QString textContent = this->toPlainText();
int length = textContent.count();
int maxLength = maxLen; // 最大字符数
if(length > maxLength)
{
int position = this->textCursor().position();
QTextCursor textCursor = this->textCursor();
textContent.remove(position - (length - maxLength), length - maxLength);
this->setText(textContent);
textCursor.setPosition(position - (length - maxLength));
this->setTextCursor(textCursor);
}