0

我想在 Qt 中使用QTextEdit. 我想获取用户命令并在其中打印结果QTextEdit

下面的代码返回的全部内容QTextEdit

text_editor.toPlainText().toAscii();

但我不知道如何区分用户输入的内容和之前打印的内容。这样做的正确方法是什么?

4

2 回答 2

1

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

This is much easier than trying to do everything with one widget.

于 2013-04-11T15:06:06.097 回答
1

重新实现按键事件处理程序以完成正常工作,同时也保存用户键入的数据。一旦按下回车,单独保存的文本将被执行,然后被清除。

于 2013-04-11T11:45:44.250 回答