Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Delete whole line : QTextEdit
Forum Update on Monday, May 27th 2025

Delete whole line : QTextEdit

Scheduled Pinned Locked Moved General and Desktop
5 Posts 1 Posters 10.0k Views
  • 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 Offline
    Y Offline
    Yash
    wrote on 13 Sept 2010, 16:32 last edited by
    #1

    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
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on 13 Sept 2010, 17:12 last edited by
      #2

      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
      0
      • Y Offline
        Y Offline
        Yash
        wrote on 13 Sept 2010, 17:41 last edited by
        #3

        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
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on 14 Sept 2010, 00:46 last edited by
          #4

          [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
          0
          • Y Offline
            Y Offline
            Yash
            wrote on 14 Sept 2010, 10:39 last edited by
            #5

            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
            0

            1/5

            13 Sept 2010, 16:32

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved