How to do it...

To create a TCP client in Qt 5, let's do the following:

  1. First off, let's create a new Qt Widgets Application project from Files | New File or Project.
  2. Once the project has been created, let's open up mainwindow.ui and set up the GUI as shown in the following diagram. Please note that the layout direction of the central widget has to be vertical:
  1. Then, right-click on the push button that says Connect and create a clicked() slot function from the menu. Then, repeat the same step on the Send button as well. As a result, two slot functions will be created for you in the source code, which may or may not look like what we see ...

Get Qt5 C++ GUI Programming Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.