Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to emulate a shell-like scripting environment with QTextEdit? [duplicate]

[Goal]

A simple shell prompt with QTextEdit, or any other appropriate Qt ways.

(Using QScriptEngine as an ECMA script interpreter is assumed)


[Example]

MATLAB

enter image description here

Python

enter image description here

In a shell prompt, the command line part is editable while the other parts are not. For MATLAB, only the line after the last >> is editable; for Python shell, only the line after the last >>> is editable.


[Workaround]

This is the first idea appear in my mind:

enter image description here

Using QTextEdit as read-only and QLineEdit as a command entry. For the purpose of pure functionality, it's acceptable, but not good enough.

[Question]

Actually the same question could be found here: Implementing a GUI Shell in qt, and the accepted answer is just the same as this workaround. Just like I said, the workaround is not good enough. I am wondering if it's possible to emulate a shell prompt with Qt? Currently, QTextEdit seems to be the best class to start.

Any ideas are welcome. Codes are welcome too but not needed, all I need are just some hints and directions.

like image 944
Tay2510 Avatar asked Nov 26 '25 17:11

Tay2510


1 Answers

You can take a look at QConsole which is a custom widget that implements a basic console and inherits from QTextEdit.

like image 64
Nejat Avatar answered Nov 29 '25 06:11

Nejat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!