Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Delete whole line : QTextEdit

    General and Desktop
    1
    5
    9260
    Loading More Posts
    • 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.
    • Y
      Yash last edited by

      This is one way to delete whole line from QTextEdit.

      You have any more?

      me is pointer to qtextedit

       @         me->setFocus();
          int pos;
          QTextCursor tc= me->textCursor();
          pos=tc.columnNumber();
          tc.select(QTextCursor::LineUnderCursor);
          QString str=tc.selectedText();
          tc.removeSelectedText();
      
          tc.movePosition(QTextCursor::NextBlock,QTextCursor::MoveAnchor);
          tc.insertText(str);
          tc.insertBlock();
          tc.movePosition(QTextCursor::PreviousBlock,QTextCursor::MoveAnchor);
          tc.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor);
          me->setTextCursor(tc);
          return true;
      

      @

      http://kineticwing.com : Web IDE, QSS Editor
      http://speedovation.com : Development Lab

      1 Reply Last reply Reply Quote 0
      • ?
        Guest last edited by

        You can position a cursor at beginning of the line and imitate key press CTRL+K, the docs say this key binding should work and delete rest of line, but it didn't work for me :(

        1 Reply Last reply Reply Quote 0
        • Y
          Yash last edited by

          Neither for me

          Many shortcut keys are not working as per doc or expectations.

          My solution working nicely. Only in this new version 4.6.3 it stops deleting empty lines.

          http://kineticwing.com : Web IDE, QSS Editor
          http://speedovation.com : Development Lab

          1 Reply Last reply Reply Quote 0
          • ?
            Guest last edited by

            [quote author="Yash" date="1284399692"]
            Many shortcut keys are not working as per doc or expectations.
            Only in this new version 4.6.3 it stops deleting empty lines.[/quote]

            I think you should log a bug for shortcut keys not working in "http://bugreports.qt.nokia.com":http://bugreports.qt.nokia.com

            I'm on 4.7RC and since there is no selection, the empty line is not removed. Probably you should move the cursor to the beginning of the next line before making the selection. The line break will also be included in your selection and then you can remove the whole line ...

            1 Reply Last reply Reply Quote 0
            • Y
              Yash last edited by

              It was working on 4.6.2 perfectly.

              Yea I'll post bugs. Just want to make sure it just happening with me or others also having same issue.

              http://kineticwing.com : Web IDE, QSS Editor
              http://speedovation.com : Development Lab

              1 Reply Last reply Reply Quote 0
              • First post
                Last post