Incoming data and the end of the pipe is not appended to the textarea and I don't see any mistake in the code. Could you give me a hand please ?

Qt Code:
  1. //******************** The declaration file
  2. #ifndef IRC_CONNECTION_H_
  3. # define IRC_CONNECTION_H_
  4. # include <QTcpSocket>
  5. class QTcpSocket;
  6.  
  7. class QBuffer;
  8.  
  9. class IrcConnection : public QTcpSocket {
  10. Q_OBJECT
  11.  
  12. public:
  13. IrcConnection(QTcpSocket *parent = 0);
  14. ~IrcConnection();
  15. signals:
  16. void incomingIrcMessage(QString &);
  17. private slots:
  18. void receiveMessage();
  19. void ircRegister();
  20. private:
  21. QBuffer *buffer;
  22. };
  23.  
  24. #endif //IRC_CONNECTION_H_
  25.  
  26. //******************** The implementation file
  27.  
  28. #include "IrcConnection.h"
  29. #include <QBuffer>
  30. #include <QTcpSocket>
  31. #include <QString>
  32. #include <QObject>
  33.  
  34. IrcConnection::IrcConnection(QTcpSocket *parent) : QTcpSocket(parent) {
  35. buffer = new QBuffer(this);
  36. QObject::connect(this,SIGNAL(readyRead()),this,SLOT(receiveMessage()));
  37. QObject::connect(this,SIGNAL(connected()),this,SLOT(ircRegister()));
  38. }
  39.  
  40. IrcConnection::~IrcConnection() {
  41. //TODO cleanup
  42. }
  43. void IrcConnection::receiveMessage() {
  44. qint64 bytes = buffer->write(readAll());
  45. buffer->seek(buffer->pos() - bytes);
  46. while(buffer->canReadLine()) {
  47. QString line = buffer->readLine();
  48. emit incomingIrcMessage(line);
  49. }
  50. }
  51. void IrcConnection::ircRegister() {
  52. write("NICK kdsjghsdkjghsdkjgnUSER "anonymous.com" "irc.undernet.org" :http://localhostn");
  53. }
  54.  
  55. //******************** main.cpp
  56. #include <QApplication>
  57. #include <QVBoxLayout>
  58. #include <QTextEdit>
  59. #include <QtGlobal>
  60. #include "IrcConnection.h"
  61.  
  62. int main(int argc, char *argv[]) {
  63. QApplication app(argc,argv);
  64. QVBoxLayout *vbox = new QVBoxLayout;
  65. QTextEdit *textarea = new QTextEdit;
  66. vbox->addWidget(textarea);
  67. textarea->setReadOnly(true);
  68.  
  69. IrcConnection *irc = new IrcConnection;
  70.  
  71. QObject::connect(irc,SIGNAL(incomingIrcMessage(QString &)),textarea,SLOT(append(QString &)));
  72. QString host("irc.freenode.org");
  73. qint16 port = 6667;
  74. textarea->append("Connecting...n");
  75. qDebug("Connecting...");
  76. irc->connectToHost(host,port);
  77. textarea->show();
  78. return app.exec();
  79. }
To copy to clipboard, switch view to plain text mode