Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextCursor position out of range..
Qt 6.12 LTS is out! See what's new in the release blog

QTextCursor position out of range..

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 3.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abdullahzubair109
    wrote on last edited by
    #1

    i am using a plaintextedit to show files..unfortunately hen i try to add a new line, console says :

    QTextCursor::setPosition: Position out of range
    
    
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      hi
      how do you add the new line ?

      https://stackoverflow.com/questions/26578319/error-when-im-trying-to-set-text-in-qtextedit

      A 2 Replies Last reply
      0
      • mrjjM mrjj

        hi
        how do you add the new line ?

        https://stackoverflow.com/questions/26578319/error-when-im-trying-to-set-text-in-qtextedit

        A Offline
        A Offline
        abdullahzubair109
        wrote on last edited by
        #3

        @mrjj i already truied this stackoverflow solution, but didn't work

        1 Reply Last reply
        0
        • mrjjM mrjj

          hi
          how do you add the new line ?

          https://stackoverflow.com/questions/26578319/error-when-im-trying-to-set-text-in-qtextedit

          A Offline
          A Offline
          abdullahzubair109
          wrote on last edited by
          #4

          @mrjj i use insertPlainText() to append new text.. when i move the cursor to next line, this console warning appears

          mrjjM 1 Reply Last reply
          0
          • A abdullahzubair109

            @mrjj i use insertPlainText() to append new text.. when i move the cursor to next line, this console warning appears

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @abdullahzubair109
            but is next line valid ?
            you can try

            moveCursor(QTextCursor::Start);
            moveCursor(QTextCursor::End);
            and see if its then in a valid posistion.

            A 1 Reply Last reply
            1
            • mrjjM mrjj

              @abdullahzubair109
              but is next line valid ?
              you can try

              moveCursor(QTextCursor::Start);
              moveCursor(QTextCursor::End);
              and see if its then in a valid posistion.

              A Offline
              A Offline
              abdullahzubair109
              wrote on last edited by
              #6

              @mrjj warning is caused by this : https://code.woboq.org/qt5/qtbase/src/gui/text/qtextcursor.cpp.html#_ZN11QTextCursor11setPositionEiNS_8MoveModeE

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt
              • Unsolved