QTextCursor position at any line and column
-
Hi, is there any posibility to move text cursor at any line and column in QTextEdit (even if it's empty)? As I understood cursor moves only relative to existing text in widget. Can I change this behavior?
I need it for telnet response, which has ASCII ESC sequence. It tell's me position where i need to display next block of data.
The only thing i can do now is insert \n character Y times and spaces X times to positioning text.
Is this the only solution? Thanks.
-
Hi, is there any posibility to move text cursor at any line and column in QTextEdit (even if it's empty)? As I understood cursor moves only relative to existing text in widget. Can I change this behavior?
I need it for telnet response, which has ASCII ESC sequence. It tell's me position where i need to display next block of data.
The only thing i can do now is insert \n character Y times and spaces X times to positioning text.
Is this the only solution? Thanks.
@04CH
Hello and welcome.I suspect that (inserting blank lines columns to reach a particular "position") probably is the only way to do it.
QTextEdit
has a backing document for its content (QTextEdit::document()). So if you think about it that would have no way of representing "there is some text at some arbitrary (row, column) position". As https://doc.qt.io/qt-6/qtextedit.html#details states:QTextEdit works on paragraphs and characters.
If you really want to do a "terminal emulator" have a look at how e.g. QTermWidget does it. This maintains an array/list of lines with a fixed number of columns per line (as terminals like xterm do). It does not use anything like a
QTextEdit
. Rather it just uses aQWidget
andQPainter::drawText()
to write characters, so that they can appear wherever desired, see TerminalDisplay.cpp. This is very different from aQTextEdit
/document approach. And btw as you can see a terminal emulator is really quite a lot of code! -
@04CH
Hello and welcome.I suspect that (inserting blank lines columns to reach a particular "position") probably is the only way to do it.
QTextEdit
has a backing document for its content (QTextEdit::document()). So if you think about it that would have no way of representing "there is some text at some arbitrary (row, column) position". As https://doc.qt.io/qt-6/qtextedit.html#details states:QTextEdit works on paragraphs and characters.
If you really want to do a "terminal emulator" have a look at how e.g. QTermWidget does it. This maintains an array/list of lines with a fixed number of columns per line (as terminals like xterm do). It does not use anything like a
QTextEdit
. Rather it just uses aQWidget
andQPainter::drawText()
to write characters, so that they can appear wherever desired, see TerminalDisplay.cpp. This is very different from aQTextEdit
/document approach. And btw as you can see a terminal emulator is really quite a lot of code!