qt如何获取在textedit中的输入
3个回答
推荐于2016-12-04 · 知道合伙人软件行家
关注
展开全部
QString str = ui->textedit->toPlainText(); // 这是普通文本
QString str = ui->textedit->toHtml(); // 这是富文本,即获取的是Html字友拍符串如好瞎羡果设置文本的话则神宽对应的是:
ui->textedit->setPlainText("123");
ui->textedit->setHtml("<b>123</b>");
2012-03-31
展开全部
连接document ()的contentsChange信号:
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().
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ui->textEdit->toPlainText()
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询