I am clearly doing something stupid that a newbie does, but I can't solve this. Here is my test code:
Qt Code:
  1. ui->TextEdit->setPlainText("testing\n");
  2. QTextCursor cursor( ui->TextEdit->textCursor() );
  3. cursor.movePosition (QTextCursor::End, QTextCursor::MoveAnchor);
  4. if(cursor.atEnd())
  5. {
  6. ui->TextEdit->insertPlainText("true\n");
  7. };
To copy to clipboard, switch view to plain text mode 
This prints:

true
testing

I would expect the lines in different order. What am I missing?