Latest Qt, ubuntu, C++ based app, could not using arrows and scroll
-
if using arrows or scroll getting special symbols
^[[A^[[A^[[A^A
how to fix it?if using Ubuntu terminal it gets previous command well
@JacobNovitsky
A shell running in a terminal does the "previous command" stuff, nothing inherent about keys. There is nothing to "fix". You have to explain where you are pressing arrow keys in a program. -
sorry, its terminal :)
-
sorry, its terminal :)
@JacobNovitsky
You have written a terminal with Qt and C++?
Or you are using one written by a third-party? -
@JacobNovitsky
You have written a terminal with Qt and C++?
Or you are using one written by a third-party?@JonB its qt creator output terminal in Ubuntu environment
if i call terminal with shortcut Ctrl T or just open app it works
f i call terminal from Qt creator it wont -
@JonB its qt creator output terminal in Ubuntu environment
if i call terminal with shortcut Ctrl T or just open app it works
f i call terminal from Qt creator it wont@JacobNovitsky said in Latest Qt, ubuntu, C++ based app, could not using arrows and scroll:
f i call terminal from Qt creator it wont
Please show the code where you're opening the terminal...
And I guess after opening the terminal from your app there are no "previous" commands yet. -
@JonB its qt creator output terminal in Ubuntu environment
if i call terminal with shortcut Ctrl T or just open app it works
f i call terminal from Qt creator it wont@JacobNovitsky said in Latest Qt, ubuntu, C++ based app, could not using arrows and scroll:
@JonB its qt creator output terminal in Ubuntu environment
I assume this means the option in Creator which says something like "Run a terminal".
If so, you are not understanding that this is not the same as some "Terminal" program from the OS:
- The OS opens a terminal running a shell (e.g.
bash
) for you. That shell reads what you type, runs commands for you, allows output. It interprets the arrows as going through the history and implements that. - Creator's "Run in terminal" option purely allows your Qt program to have a terminal window for input/output. It does not run some shell there. There is no history of commands to go through.
If you want an actual terminal running a shell from a Qt application, not just for plain I/O, you will need your program to use
QProcess
to spawn a suitable terminal with a shell, such asxterm
or whatever your Terminal is. - The OS opens a terminal running a shell (e.g.
-
@JacobNovitsky said in Latest Qt, ubuntu, C++ based app, could not using arrows and scroll:
@JonB its qt creator output terminal in Ubuntu environment
I assume this means the option in Creator which says something like "Run a terminal".
If so, you are not understanding that this is not the same as some "Terminal" program from the OS:
- The OS opens a terminal running a shell (e.g.
bash
) for you. That shell reads what you type, runs commands for you, allows output. It interprets the arrows as going through the history and implements that. - Creator's "Run in terminal" option purely allows your Qt program to have a terminal window for input/output. It does not run some shell there. There is no history of commands to go through.
If you want an actual terminal running a shell from a Qt application, not just for plain I/O, you will need your program to use
QProcess
to spawn a suitable terminal with a shell, such asxterm
or whatever your Terminal is.@JonB now the thing is more clear :)
can u share the code, please?having this, and this yet does nothing
#include <QCoreApplication> #include <QProcess> int main() { while(true){ QProcess process; process.start("ls"); process.waitForFinished(); QString output = process.readAllStandardOutput(); qDebug() << output; } return 0; }
- The OS opens a terminal running a shell (e.g.
-
@JonB now the thing is more clear :)
can u share the code, please?having this, and this yet does nothing
#include <QCoreApplication> #include <QProcess> int main() { while(true){ QProcess process; process.start("ls"); process.waitForFinished(); QString output = process.readAllStandardOutput(); qDebug() << output; } return 0; }
@JacobNovitsky
I don't thinkQProcess::waitForFinished()
will return since you do not have the Qt event loop running. (PutqDebug()
s in to see which line is being reached.) Get rid ofwhile
and write it as a proper Qt program. -
@JacobNovitsky
I don't thinkQProcess::waitForFinished()
will return since you do not have the Qt event loop running. (PutqDebug()
s in to see which line is being reached.) Get rid ofwhile
and write it as a proper Qt program.@JonB After two years with Qt as IDE I'm really stuck now
can you please provide working sample, to make the terminal in Ubuntu work smoothly like in Windows? -
@JonB After two years with Qt as IDE I'm really stuck now
can you please provide working sample, to make the terminal in Ubuntu work smoothly like in Windows?@JacobNovitsky said in Latest Qt, ubuntu, C++ based app, could not using arrows and scroll:
Qt as IDE
Qt isn't an IDE.
As @JonB pointed out you need running Qt event loop to be able to use signals/slots. This is very basic Qt.
To start Qt event loop you need to call https://doc.qt.io/qt-6/qapplication.html#exec like in any proper Qt application. See https://doc.qt.io/qt-6/qapplication.html for an example.