cursor.atEnd returns true, cursor is at start?
I am clearly doing something stupid that a newbie does, but I can't solve this. Here is my test code:
Code:
ui->TextEdit->setPlainText("testing\n");
if(cursor.atEnd())
{
ui->TextEdit->insertPlainText("true\n");
};
This prints:
true
testing
I would expect the lines in different order. What am I missing? :confused:
Re: cursor.atEnd returns true, cursor is at start?
The Qt doc clearly states.
QTextCursor QTextEdit::textCursor () const
Returns a copy of the QTextCursor that represents the currently visible cursor. Note that changes on the returned cursor do not affect QTextEdit's cursor; use setTextCursor() to update the visible cursor.
just use the moveCursor method form QTextEdit :p
Re: cursor.atEnd returns true, cursor is at start?
I did read the documentation, but clearly from a wrong place. Besides, you can't always rely on snippets from the Internet, as demonstrated. Thanks for pointers! :o