Launch telnet from Qt GUI application
-
I figured it out.
system("start telnet") works.
-
I figured it out.
system("start telnet") works.
@richferrara said in Launch telnet from Qt GUI application:
system("start telnet") works.
As should the code I suggested sticking with
QProcess. -
Why one needs to run a cmd.exe at all?
Simply follow the docs
QObject *parent = new QObject; ... QString program = "telnet"; QStringList arguments; arguments << "172.99.99.99"; QProcess *myProcess = new QProcess(parent); myProcess->start(program, arguments); -
Why one needs to run a cmd.exe at all?
Simply follow the docs
QObject *parent = new QObject; ... QString program = "telnet"; QStringList arguments; arguments << "172.99.99.99"; QProcess *myProcess = new QProcess(parent); myProcess->start(program, arguments);@Christian-Ehrlicher
The OP essentially claimed to have tried this and claimed it did not work:The first thing I tried was just launching telnet directly: QStringList args = {"172.99.99.99"}; // using my target IP address QProcess::startDetached("telnet.exe", {args});That is why I tried "building up" step by step with them to see what was happening. Have you tried this under Windows (which I cannot do)? The question is whether the Windows' telnet opens any kind of "terminal/console/command" window for itself, the suggestion is it does not and hence is "invisible"?
-
The windows telnet command normally runs in its own terminal window. For whatever reason, QProcess seems to only be capable of running applications in the background.
-
The windows telnet command normally runs in its own terminal window. For whatever reason, QProcess seems to only be capable of running applications in the background.
@richferrara
QProcessshould be fine. You could also try having it run, say, notepad, if you don't think it can run e.g. a UI process. Did you actually try either my code or @Christian-Ehrlicher's ? If the Windows telnet opens its own window then you ought not need to run it viacmd/start? I guess I will be quiet now as I cannot test under Windows, maybe @Christian-Ehrlicher will. -
The windows telnet command normally runs in its own terminal window. For whatever reason, QProcess seems to only be capable of running applications in the background.
@richferrara said in Launch telnet from Qt GUI application:
For whatever reason, QProcess seems to only be capable of running applications in the background.
This is wrong. Please show your code and don't use QProcess::startDetached() if you want to interact with your application.
-
@richferrara said in Launch telnet from Qt GUI application:
For whatever reason, QProcess seems to only be capable of running applications in the background.
This is wrong. Please show your code and don't use QProcess::startDetached() if you want to interact with your application.
@Christian-Ehrlicher said in Launch telnet from Qt GUI application:
and don't use QProcess::startDetached() if you want to interact with your application
Oh, really??
-
@Christian-Ehrlicher said in Launch telnet from Qt GUI application:
and don't use QProcess::startDetached() if you want to interact with your application
Oh, really??
@JonB said in Launch telnet from Qt GUI application:
@Christian-Ehrlicher said in Launch telnet from Qt GUI application:
and don't use QProcess::startDetached() if you want to interact with your application
Oh, really??
That's the whole point of this function - fire and forget
https://doc.qt.io/qt-6/qprocess.html#startDetached -
@JonB said in Launch telnet from Qt GUI application:
@Christian-Ehrlicher said in Launch telnet from Qt GUI application:
and don't use QProcess::startDetached() if you want to interact with your application
Oh, really??
That's the whole point of this function - fire and forget
https://doc.qt.io/qt-6/qprocess.html#startDetached@Christian-Ehrlicher said in Launch telnet from Qt GUI application:
and don't use QProcess::startDetached() if you want to interact with your application
and
That's the whole point of this function - fire and forget
https://doc.qt.io/qt-6/qprocess.html#startDetachedHi Christian. I am sorry but I do not agree with your statements. Under Linux at least
startDetached()causes the child process not to get killed when the parent process exits, but it is not true to say that means you do not use if you need interaction.Testing under Linux at least, where telnet does not open its own window (maybe it does under Windows, I don't know) while, say, gedit does, I see the following behaviour:
start("telnet"): runs telnet (in the background), no window, exiting Qt app kills the telnet.startDetached("telnet"): same asstart(), but exiting Qt app does not kill the telnet.start("gedit"): runs gedit, that creates its own window and interacts fine, exiting Qt app kills the gedit.startDetached("gedit"): same asstart(), but exiting Qt app does not kill the gedit.
If I want a Linux spawned telnet to be visible and have a window I have to use something like e.g.
xterm -e telnetas the command. And again that behaves as above: dies on parent exit withstart(), continues to run afterwards withstartDetached(), but same interaction in both cases.Maybe it's different under Windows and/or with telnet there, but saying that "and don't use QProcess::startDetached() if you want to interact with your application" is not the story under Linux at least. Which is why I expressed my surprise when you wrote that, as not my experience in Linux.