Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTextCursor::setPosition() not working in my QTextEdit.



  • Hi, I cannot manage to move textCursor of QTextEdit with setPosition function.
    The following instruction does not work in my Qt 5.10.0:

    this->textCursor().setPosition(0);
    

    Nothing happens. I want to move cursor to specific position in the text already written, thats why i'm not using movePosition function.

    Thanks.


  • Qt Champions 2019

    You need to set the cursor with setTextCursor(). textCursor only returns the current QTextCursor. See documentation: http://doc.qt.io/qt-5/qtextedit.html#textCursor

    "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."


Log in to reply