I want to append QTextEdit with rich text from userInput, USB or TTY Console
with limited count of displayed characters (only newest data should be visible).
I wondered to insert new block each time device has answered, but it is
inserting new paragraph (with additional break line in document).
My code:
QScrollBar *p_scroll_bar
= this
->verticalScrollBar
();
bool bool_at_bottom = (p_scroll_bar->value() == p_scroll_bar->maximum());
if(addBr)
appendText.append("<br>");
appendText
= QString("<font color = %1>%2</font>") .arg(this->_isDevice? this->_deviceColor.name() : this->_commandLineColor.name())
.arg(appendText);
this->_containingText.append( appendText );
qDebug() << appendText;
appendTextCursor.insertBlock();
appendTextCursor.beginEditBlock();
appendTextCursor.insertHtml(appendText);
appendTextCursor.endEditBlock();
if (bool_at_bottom)
{
p_scroll_bar->setValue(p_scroll_bar->maximum());
}
QScrollBar *p_scroll_bar = this->verticalScrollBar();
bool bool_at_bottom = (p_scroll_bar->value() == p_scroll_bar->maximum());
QTextCursor appendTextCursor = this->textCursor();
if(addBr)
appendText.append("<br>");
appendText = QString("<font color = %1>%2</font>")
.arg(this->_isDevice? this->_deviceColor.name() : this->_commandLineColor.name())
.arg(appendText);
this->_containingText.append( appendText );
qDebug() << appendText;
appendTextCursor.movePosition(QTextCursor::End);
appendTextCursor.insertBlock();
appendTextCursor.beginEditBlock();
appendTextCursor.insertHtml(appendText);
appendTextCursor.endEditBlock();
if (bool_at_bottom)
{
p_scroll_bar->setValue(p_scroll_bar->maximum());
}
To copy to clipboard, switch view to plain text mode
Bookmarks