Implementing a GUI wrapper in qt

I want to implement a simple GUI in Qt using QTextEdit

. I want to get custom commands and print the results to QTextEdit

.

The code below returns the whole content QTextEdit

:

text_editor.toPlainText().toAscii();

      

But I don’t know how to distinguish between what the user entered and what was typed earlier. What is the correct way to do this?

0


source to share


2 answers


Use QTextEdit for output. It supports multiple lines and you can manipulate colors using HTML. Then use a single QLineEdit line to enter commands. Place QLineEdit under QTextEdit and there you have a GUI for a simple command interface! When you enter a command in QLineEdit, also print it in QTextEdit, possibly using a different color than the command output.



It's much easier than trying to do everything with one widget.

+1


source


Override the keypress event handler for normal operation, but also preserve user input. After pressing the key, the separately saved text is saved and then cleared.



+1


source







All Articles