Disable QTextCursor Mouse click repositioning
See I have a text browser that works great, I use
insertHtml("<br>%1") for texts, and it works great.. I add this line over and over, and it makes a new line each time. Until the user clicks on the QTextBrowser (like somewhere on it), and thats when it messes up and starts inserting it in the middle of the page, or wherever the QTextBrowser is clicked.
I tried doing this to keep the cursor at the end of all the TEXT. However, this did not work:
qtxtbrowser->textCursor().clearSelection();
qtxtbrowser->textCursor().movePosition(QTextCursor::End);
qtxtbrowser->insertHtml(qsData+"<br>");
I also thought about doing something like this: qtxtbrowser->mousePressEvent(QMouseEvent(QEvent::MouseButtonPr ess, QPoint(1,1), Qt::LeftButton, ));
but I have no clue how to do this, and there are no examples anywhere I looked.
Is there a way to disable this left click feature or just keep the cursor at the bottom of all the inserted text?
Re: Disable QTextCursor Mouse click repositioning
Quote:
Originally Posted by
VireX
I tried doing this to keep the cursor at the end of all the TEXT. However, this did not work:
Code:
qtxtbrowser->textCursor().clearSelection();
qtxtbrowser
->textCursor
().
movePosition(QTextCursor::End);
qtxtbrowser->insertHtml(qsData+"<br>");
That is modifying a copy. It should be done in this way:
Code:
cursor.clearSelection();
qtextbrowser->setTextCursor(cursor); // <--
qtxtbrowser->insertHtml(qsData+"<br>");
By the way, Qt 4.2 introduces a new convenience method for moving the cursor. You could try something like this:
Code:
qtxtbrowser->insertHtml(qsData+"<br>");
Re: Disable QTextCursor Mouse click repositioning
You're amazing thank you so much :). Especially on the fast reply <3.