Dear All,
I have created a Application using Qt Network Class. I have created a SERVER and CLIENT. Here Client is sending the data to Server. In server after accepting the New connection, Server socket reads the Packet data from Client. After analysing it. It should send the data to another Page(Mulitple MainWindows) on the same Application of the Server. Here I'm able to see all Debug messages. In server after logging in, It takes to child window is there. Here Lineedit are declared. Here the Data should Appear after checking the start bit after ReadLine in the child Window.
SERVER Code:
{
hAddr.setAddress("192.168.64.55");
//server->listen(hAddr,1234);
Client Side:
qDebug("Listening to new connection");
}
void TeamStatus::on_newconn()
{
socket=server->nextPendingConnection();
{
qDebug("new connection1 established");
}
connect(socket,SIGNAL(readyRead()),this,SLOT(read_socket()));
}
void TeamStatus::read_socket()
{
if(buffer.startsWith("1"))
{
qDebug()<<buffer;
qDebug("Next Page");
qDebug()<<buf;
tempage.le1->setText(buf); //This the another page where Line Edit is declared as le1... TEAMPAGE is made object at TEAMSTATUS.H file as teampage
}
if(buffer.startsWith("2"))
{
qDebug()<<buffer;
qDebug("Next Page");
qDebug()<<buf;
tempage.le2->setText(buf); //This the another page where Line Edit is declared as le1... TEAMPAGE is made object at TEAMSTATUS.H file as teampage
}
{
QHostAddress hAddr;
hAddr.setAddress("192.168.64.55");
//server->listen(hAddr,1234);
server->listen(QHostAddress::Any,1234);
Client Side:
qDebug("Listening to new connection");
}
void TeamStatus::on_newconn()
{
socket=server->nextPendingConnection();
if((socket->state()==QTcpSocket::ConnectedState))
{
qDebug("new connection1 established");
}
connect(socket,SIGNAL(readyRead()),this,SLOT(read_socket()));
}
void TeamStatus::read_socket()
{
QByteArray buffer= socket->readLine();
if(buffer.startsWith("1"))
{
qDebug()<<buffer;
qDebug("Next Page");
qDebug()<<buf;
tempage.le1->setText(buf); //This the another page where Line Edit is declared as le1... TEAMPAGE is made object at TEAMSTATUS.H file as teampage
}
if(buffer.startsWith("2"))
{
qDebug()<<buffer;
qDebug("Next Page");
qDebug()<<buf;
tempage.le2->setText(buf); //This the another page where Line Edit is declared as le1... TEAMPAGE is made object at TEAMSTATUS.H file as teampage
}
To copy to clipboard, switch view to plain text mode
CLIENT CODE
void TCPClient::write()
QString Data
="",Data1
=this
->le
->text
();
CHAT="1";
Data.append(CHAT);
Data.append(Data1);
socket->write(Data.toUtf8().constData());
qDebug("Client Sent 1 to Server");
socket->flush();
}
void TCPClient::write1()
{
QString Data
="",Data1
=this
->le
->text
();
CHAT="2";
Data.append(CHAT);
Data.append(Data1);
socket->write(Data.toUtf8().constData());
qDebug("Client Sent 2 to server");
socket->flush();
}
void TCPClient::write()
QString Data="",Data1=this->le->text();
CHAT="1";
Data.append(CHAT);
Data.append(Data1);
socket->write(Data.toUtf8().constData());
qDebug("Client Sent 1 to Server");
socket->flush();
}
void TCPClient::write1()
{
QString Data="",Data1=this->le->text();
CHAT="2";
Data.append(CHAT);
Data.append(Data1);
socket->write(Data.toUtf8().constData());
qDebug("Client Sent 2 to server");
socket->flush();
}
To copy to clipboard, switch view to plain text mode
Please Help I'm Stuck up here
I'm not getting the text at the Server Lineedits. In debug msgs in console we can see, but not on the Application Window.
Bookmarks