qt如何获取在textedit中的输入
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了qt如何获取在textedit中的输入相关的知识,希望对你有一定的参考价值。
QString str = ui->textedit->toPlainText(); // 这是普通文本
QString str = ui->textedit->tohtml(); // 这是富文本,即获取的是Html字符串
如果设置文本的话则对应的是:
ui->textedit->setPlainText("123");
ui->textedit->setHtml("<b>123</b>");
void QTextDocument::contentsChange ( int position, int charsRemoved, int charsAdded ) [signal]
This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied.
Information is provided about the position of the character in the document where the change occurred, the number of characters removed (charsRemoved), and the number of characters added (charsAdded).
The signal is emitted before the document's layout manager is notified about the change. This hook allows you to implement syntax highlighting for the document.
See also QAbstractTextDocumentLayout::documentChanged() and contentsChanged().
参考资料:http://qt-project.org/doc/qt-4.8/qtextdocument.html#documentLayoutChanged
参考技术B ui->textEdit->toPlainText()本回答被提问者采纳以上是关于qt如何获取在textedit中的输入的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 c && 调用 c++ 函数将应用程序输出重定向到 Qt 中的 textEdit