-
Notifications
You must be signed in to change notification settings - Fork 267
feat(example): add RemoteTerm example target and Qt6 fixes #595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
yangwei-x
commented
Sep 15, 2025
- Add optional RemoteTerm example (BUILD_EXAMPLE_REMOTETERM) with CMake target 'remoteterm'
- Use QStringLiteral for usage message in RemoteTerm main.cpp for Qt6 compatibility.
Add optional RemoteTerm example (BUILD_EXAMPLE_REMOTETERM) with CMake target 'remoteterm' Use QStringLiteral for usage message in RemoteTerm main.cpp for Qt6 compatibility.
@yan12125 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some thoughts after a quick glance. Didn't test them yet
Examples using QTermWidget | ||
========================== | ||
|
||
This directory contains minimal examples showing how to embed and use `QTermWidget` in both C++ and Python (PyQt/PySide) applications. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently there is only PyQt binding, no official one for PySide yet.
-------- | ||
* `cpp/main.cpp` – Basic single–terminal C++ example with menu actions (Find / Copy / Paste / About Qt) and runtime selection of color schemes and key bindings via command‑line arguments. | ||
* `cpp/RemoteTerm/` – A simple remote client example that connects to a TCP server exposing a pseudo terminal. Local keystrokes are sent to the remote host; data received over the socket is written into the local PTY backing the widget. | ||
* `pyqt/` – Python examples (PyQt/PySide) demonstrating how to instantiate and configure the terminal widget from Python. See the files inside for details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto for PySide
mkdir -p build | ||
cd build | ||
cmake -DBUILD_EXAMPLE=ON -DBUILD_EXAMPLE_REMOTETERM=ON .. | ||
cmake --build . -j |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I'm not a fan of -j
, which often makes the system hang, especially on not-so-powerful machines.
|
||
Python Examples | ||
--------------- | ||
Install the Python bindings (PyQt6 recommended for Qt6 builds) and run the scripts directly, for example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: PyQt5 is no longer supported. Only PyQt6 is supported, so it is not only recommended, but also needed for the Python example.
Running
Apparently the signal is renamed. Here is a quick fix: diff --git a/examples/cpp/RemoteTerm/remoteterm.cpp b/examples/cpp/RemoteTerm/remoteterm.cpp
index 551ac25..b48be65 100644
--- a/examples/cpp/RemoteTerm/remoteterm.cpp
+++ b/examples/cpp/RemoteTerm/remoteterm.cpp
@@ -18,7 +18,9 @@ RemoteTerm::RemoteTerm(const QString &ipaddr, quint16 port, QWidget *parent)
QByteArray data = socket->readAll();
write(this->getPtySlaveFd(), data.data(), data.size());
});
- connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(atError()));
+ connect(socket, &QTcpSocket::errorOccurred, [this](QAbstractSocket::SocketError){
+ atError();
+ });
// Here we start an empty pty.
this->startTerminalTeletype(); After this, I got "Connection refused" for a random IP and port as expected. It would be great to have an example for the server to actually test the functionality of this program. |