Vivek1982
11th November 2013, 13:45
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:
{
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
}
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();
}
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.
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:
{
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
}
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();
}
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.