Delete whole line : QTextEdit
-
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;
@
-
[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 ...