Delete whole line : QTextEdit
-
wrote on 13 Sept 2010, 16:32 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;
@
-
wrote on 13 Sept 2010, 17:12 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 :(
-
wrote on 13 Sept 2010, 17:41 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.
-
wrote on 14 Sept 2010, 00:46 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 ...
-
wrote on 14 Sept 2010, 10:39 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.
1/5