Append text on where cursor pointed | QPlainText
-
Hello,can i ask how do i append the text where the text pointer pointed?
Like in normal code editor,when u press tab it append 4 space
this is my code:
void keyPressEvent (QKeyEvent * event) { if(event->key() == Qt::Key_Tab ) { } }
what to do to add 4 space to where the text pointer pointed
please help
-
Imo not possible with QPlainTextEdit - you have to use QTextEdit
-
@Christian-Ehrlicher But i need to use plaintext,cuz i alr set much thing for it.Any other way to do that?
-
Imo not possible with
QPlainTextEdit
- you have to useQTextEdit
Why do you say this? You know better than I, but from https://doc.qt.io/qt-5/qplaintextedit.html#using-qplaintextedit-as-an-editor
Selection of text is handled by the
QTextCursor
class, which provides functionality for creating selections, retrieving the text contents or deleting selections. You can retrieve the object that corresponds with the user-visible cursor using thetextCursor()
method.Isn't that what @ELEMENTICY needs?
-
@JonB You're right - I was under the impression that QPlainTextEdit killed this in favor of speed. But it's not the case.
-
Hi
I think you can just do
ui->plainTextEdit->insertPlainText ("\t\t\t\tTEXT");