Skip to content

Conversation

yangwei-x
Copy link

  • 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.
@tsujan
Copy link
Member

tsujan commented Sep 15, 2025

@yan12125
Could you review it? It's mainly about README and cmake.

Copy link
Member

@yan12125 yan12125 left a 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.
Copy link
Member

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.
Copy link
Member

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
Copy link
Member

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:
Copy link
Member

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.

@yan12125
Copy link
Member

Running remoteterm gives this:

qt.core.qobject.connect: QObject::connect: No such signal QTcpSocket::error(QAbstractSocket::SocketError)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants