Hi.

I ve got a plugin in which a write some data into the socket:

Qt Code:
  1. ...
  2. array = new QByteArray();
  3. QDataStream stream(array, QIODevice::WriteOnly);
  4. stream.setVersion(QDataStream::Qt_4_2);
  5.  
  6. QString name = "Program Viewer";
  7. stream << quint32(Data::PluginData) << name << quint32(ProgramViewerMenu::NewImage) << shot.toImage();
  8. screen = shot.toImage();
  9.  
  10. return array;
  11. ...
  12.  
  13. socket->write(array);
To copy to clipboard, switch view to plain text mode 

And in another program I have slot read() which is connected to readyRead() signal of socket.

Qt Code:
  1. void Connection::read()
  2. {
  3. DataThread *thread = new DataThread(socket, this);
  4.  
  5. connect(thread, SIGNAL(serverData(QByteArray)), this, SLOT(serverData(QByteArray)));
  6. connect(thread, SIGNAL(pluginData(QByteArray)), this, SLOT(pluginData(QByteArray)));
  7. connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()) );
  8.  
  9. thread->start();
  10. }
To copy to clipboard, switch view to plain text mode 

DataThread run() function:

Qt Code:
  1. void DataThread::run()
  2. {
  3. QByteArray array;
  4. array = socket->readAll();
  5.  
  6. QDataStream streamOut(array);
  7. streamOut.setVersion(QDataStream::Qt_4_2);
  8.  
  9. quint32 dataType;
  10. streamOut >> dataType;
  11. qDebug() << "data thread dataType" << dataType;
  12. /* QString name;
  13. streamOut >> name;
  14.  
  15. qDebug() << name;*/
  16.  
  17. if (dataType == Data::ServerData)
  18. emit serverData(array);
  19. if (dataType == Data::PluginData)
  20. emit pluginData(array);
  21. }
To copy to clipboard, switch view to plain text mode 

pluginData signal of DataThread is connected to pluginData slot. In this slot I want to read plugin name which was written in plugin function.

Qt Code:
  1. void Connection::pluginData(QByteArray array)
  2. {
  3. QDataStream streamOut(array);
  4. streamOut.setVersion(QDataStream::Qt_4_2);
  5.  
  6. QString name;
  7. streamIn >> name;
  8.  
  9. qDebug() << name;
  10. }
To copy to clipboard, switch view to plain text mode 

qDebug() << name gives me nothing, null string but I have no idea why. When I tray to read plugin name in thread class before returning array it works. Whats wrong?

Sorry about me english.