Клиент #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->connect(&m_client, SIGNAL(readyRead()), SLOT(readyRead())); m_client.connectToHost("127.0.0.1", 7777); } MainWindow::~MainWindow() { delete ui; } void MainWindow::readyRead() { QByteArray data = m_client.readAll(); ui->plainTextEdit->appendPlainText(QString(data)); } void MainWindow::on_pushButton_clicked() { // ........... } Сервер #include "mainwindow.h" #include "ui_mainwindow.h" #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); m_server.listen(QHostAddress::Any, 7777); this->connect(&m_server, SIGNAL(newConnection()), SLOT(NewConnection())); } MainWindow::~MainWindow() { delete ui; } void MainWindow::NewConnection() { QPointer client(m_server.nextPendingConnection()); this->connect(client.data(), SIGNAL(readyRead()), SLOT(readyRead())); m_clients.append(client); ui->plainTextEdit->appendPlainText("NewConnection"); } void MainWindow::readyRead() { //......... }