Results 1 to 4 of 4

Thread: Network Programming Error/Line Edit

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2013
    Posts
    107
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Network Programming Error/Line Edit

    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:
    Qt Code:
    1. {
    2. QHostAddress hAddr;
    3. hAddr.setAddress("192.168.64.55");
    4.  
    5. //server->listen(hAddr,1234);
    6. server->listen(QHostAddress::Any,1234);
    7.  
    8.  
    9. Client Side:
    10. qDebug("Listening to new connection");
    11. }
    12.  
    13. void TeamStatus::on_newconn()
    14. {
    15. socket=server->nextPendingConnection();
    16. if((socket->state()==QTcpSocket::ConnectedState))
    17. {
    18. qDebug("new connection1 established");
    19. }
    20. connect(socket,SIGNAL(readyRead()),this,SLOT(read_socket()));
    21. }
    22.  
    23. void TeamStatus::read_socket()
    24. {
    25. QByteArray buffer= socket->readLine();
    26.  
    27.  
    28.  
    29.  
    30. if(buffer.startsWith("1"))
    31. {
    32. qDebug()<<buffer;
    33. qDebug("Next Page");
    34. qDebug()<<buf;
    35. 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
    36. }
    37.  
    38. if(buffer.startsWith("2"))
    39. {
    40. qDebug()<<buffer;
    41. qDebug("Next Page");
    42. qDebug()<<buf;
    43. 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
    44. }
    To copy to clipboard, switch view to plain text mode 


    CLIENT CODE
    Qt Code:
    1. void TCPClient::write()
    2. QString Data="",Data1=this->le->text();
    3. CHAT="1";
    4. Data.append(CHAT);
    5. Data.append(Data1);
    6. socket->write(Data.toUtf8().constData());
    7. qDebug("Client Sent 1 to Server");
    8. socket->flush();
    9. }
    10. void TCPClient::write1()
    11. {
    12. QString Data="",Data1=this->le->text();
    13. CHAT="2";
    14. Data.append(CHAT);
    15. Data.append(Data1);
    16. socket->write(Data.toUtf8().constData());
    17. qDebug("Client Sent 2 to server");
    18. socket->flush();
    19. }
    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.
    Last edited by Vivek1982; 11th November 2013 at 13:47. Reason: updated contents

Similar Threads

  1. QTableView line edit clears the text on edit
    By PlasticJesus in forum Qt Programming
    Replies: 5
    Last Post: 14th March 2015, 19:06
  2. Network Raw Programming
    By havij000 in forum Qt Programming
    Replies: 6
    Last Post: 28th August 2013, 11:49
  3. Replies: 3
    Last Post: 26th August 2010, 08:57
  4. qt4 network programming
    By linuxqt in forum General Programming
    Replies: 3
    Last Post: 12th March 2009, 15:41
  5. Replies: 8
    Last Post: 15th May 2007, 09:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.