Search code examples
qtubuntuqt5terminal-emulator

How i can get Ubuntu terminal's list from Qt


In my app i want to open ssh in terminal-emulator for user. Now i'am using QProcess like this:

QProcess _localhostConnection;
_localhostConnection.start(QString("gnome-terminal"), QStringList("--command=ssh 127.0.0.1"));

But the problem is there can be no gnome-terminal on another computer. Another computer has Ubuntu. How can i get installed terminal's list in Qt on Ubuntu?


Solution

  • Try calling x-terminal-emulator instead. Almost all Debian-based systems use the update-alternatives package (in conjunction with virtual packages like x-terminal-emulator) to bookkeep programs with similar functions, such as Internet browsers, editors, command shells, et cetra. Calling x-terminal-emulator will launch the default terminal emulator set by the user. Read more about update-alternatives here: https://manpages.ubuntu.com/manpages/xenial/en/man1/update-alternatives.1.html

    However, hardcoding --command=ssh 127.0.0.1 isn't very wise if you are aiming to support all terminal emulators. XTerm, for example, won't accept that parameter syntax.