Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Embedded Console in Qt GUI
shoag last edited by
Hi, I'm a relatively new Qt user and would like a bit of advice. I'm working on a C++ Qt program where it would be useful for "advanced" users to have access to a terminal or console window embedded in the GUI itself. Is there a stock widget that models the behaviour of a console window (Captures input and can display output messages)? If not, can anyone offer some potentially useful implementation tips or reccomend which widgets I should look at first? I currently have a QTextBrowser that I am directing output messages to, but that particular widget can not capture user input. Thanks for your help.
frankcyblogic.de last edited by
Maybe a QPlainText? You could overload keyPressEvent() to make it behave more like a terminal.
diegosarmentero last edited by
Maybe you can take a look at this files:
Using that I wrote a Python Console, maybe you can use something like that and send commands to the OS and print the answer in that QPlainTextEdit.
You can see at the ConsoleWidget Class how to handle history and avoid to let the user modify everywhere in the QPlainTextEdit, to behave as a console.
Please take look at this open source project:
It's a Qt / C++ console widget, currently supporting TCL and Python languages but it is completely extensible...
I am working on that too, everything you need it's just to handle position of cursor inside of keyPressEvent.
[quote author="Peppy" date="1346602509"]I am working on that too, everything you need it's just to handle position of cursor inside of keyPressEvent.[/quote]
It's indeed an important part but you quickly realize that more and more features must be added : Just take a look at QConsole code and try it...
kmatheussen last edited by
It uses a label to display output text and opens a new QLineEdit widget for each input line.
No thanks, it's under GPL, I won't use that due to license infringements.
[quote author="Peppy" date="1346609672"]@Houssem:
No thanks, it's under GPL, I won't use that due to license infringements.[/quote]
I've just changed it to LGPL v2, as Qt licence !
Please let me know if this is sufficient or more things need to be done...
Sorry man, you are using tcl.h (inside of QTclConsole), what is non-standard library, thus I can't compile it.
zester last edited by
There is QTermWidget
Here is an example application using it.