void CKMAddformatdialog::on_textEdit_format_content_textChanged()
{
QString textContent = ui->textEdit_format_content->toPlainText();
int length = textContent.count();
int maxLength = MAXLEN; // 最大字符数
if(length > maxLength)
{
int position = ui->textEdit_format_content->textCursor().position();
QTextCursor textCursor = ui->textEdit_format_content->textCursor();
textContent.remove(position - (length - maxLength), length - maxLength);
ui->textEdit_format_content->setText(textContent);
textCursor.setPosition(position - (length - maxLength));
ui->textEdit_format_content->setTextCursor(textCursor);
}
}
QTextEdit 限制最大输入
最新推荐文章于 2024-04-15 10:18:43 发布