Good day,

I have a server with the method for read data from database and send a client(If you have suggestion is very accepted)

Qt Code:
  1. void ServerThings::readClient()
  2. {
  3. QTcpSocket *clientSocket = static_cast<QTcpSocket*>(sender());
  4. QDataStream in(clientSocket);
  5. //in.setVersion(QDataStream::Qt_5_10);
  6. for (;;)
  7. {
  8. if (!m_nNextBlockSize)
  9. {
  10. if (clientSocket->bytesAvailable() < sizeof(quint16)) { break; }
  11. in >> m_nNextBlockSize;
  12. }
  13.  
  14. if (clientSocket->bytesAvailable() < m_nNextBlockSize) { break; }
  15. QString str;
  16. in >> str;
  17.  
  18. emit gotNewMesssage(str);
  19.  
  20. m_nNextBlockSize = 0;
  21.  
  22. if (sendToClient(clientSocket, str) == -1)
  23. {
  24. qDebug() << "Some error occured";
  25. }
  26. }
  27. }
  28.  
  29.  
  30. qint64 ServerThings::sendToClient(QTcpSocket *socket, const QString &str)
  31. {
  32.  
  33.  
  34. QByteArray arrBlock;
  35. Q_ASSERT(socket);
  36. QDataStream out(&arrBlock,QIODevice::WriteOnly);
  37. QSqlQuery query;
  38. query.prepare("SELECT * FROM tabripa where Nbusta =(?)");
  39. query.bindValue(0, str);
  40. query.exec();
  41. while (query.next()) {
  42. const QSqlRecord record = query.record();
  43. for(int i=0; i < record.count(); i++)
  44. out << record.value(i).toString();
  45. }
  46. return socket->write(arrBlock);
  47.  
  48.  
  49. }
To copy to clipboard, switch view to plain text mode 

I now I should receive the data and transform the various records into (string, int, float etc) but I don't know how to do it, can you help me?