Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9016315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:57:57+00:00 2026-06-16T03:57:57+00:00

I am developing a simple tcp server with qt. There is no problem with

  • 0

I am developing a simple tcp server with qt. There is no problem with that. But the problem is, i have listed every connected client in a listbox and i want to see the incoming data only from the selected client from the listbox but i can only see the last connected client’s messages.
here is the code,
this is the constructor part

server = new QTcpServer();
    client = new QTcpSocket();
    connect(server, SIGNAL(newConnection()),this, SLOT(acceptConnection()));
    server->listen(QHostAddress::Any, ui->txtPort->text().toInt(bool(),10));
    if(server->isListening())
    {
        ui->statusBar->showMessage("Server Started..");
    }
    else
    {
        ui->statusBar->showMessage("Server Not Started..");
    }

    connect(client,SIGNAL(disconnected()),this,SLOT(client_disconnected()));

    connect(ui->listWidget,SIGNAL(clicked(QModelIndex)),this,SLOT(selected_client()));

here is acceptConnection() part

client = server->nextPendingConnection();

    ui->listWidget->insertItem(client_count,client->peerAddress().toString());
    client_count++;

and this is the listWidget item’s selected item event

ui->txtRead->clear();
    selected_client_index = ui->listWidget->currentIndex().row();
    connect(client, SIGNAL(readyRead()),this, SLOT(startRead()));

and lastly the startRead() part

   char buffer[1024] = {0};
   client->read(buffer, client->bytesAvailable());
   qDebug() << buffer;
   ui->txtRead->insertPlainText(buffer);

How can i select the specific client and show its messages ?
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:57:59+00:00Added an answer on June 16, 2026 at 3:57 am

    You should not use client in startRead, but some selectedClient, that You remembers in selected_client() SLOT.
    As for now, when You use client = server->nextPendingConnection(), You are losing any previous clients. You should save them into some QList<QTcpSocket*>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a simple php mvc that'll do the bare minimum but work how
I'm developing a simple Android application that would have an action bar on the
I have 6 months experience with Android, developing simple UI-based applications. Now I want
INTRO I have a TCP/HTTP server that supports plugins in form of Shared Libraries
Im developing a simple application that have a line like this: string[] values =
I'm developing a client/server app in which the client calls the WCF service every
I have been developing simple web services and clients using JBoss but now I
I am currently developing a simple application in python that connects to a server.
I developing the simple UIApplication in which i want to crop the UIImage (in
I am developing a simple tool that will be used across a variety of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.