hi ,folks,i have a problem in qbytearray to float array,i received float array in udp,but return value is 0,what's wrong with me?can u help me?tks.i have searched in google.
the sender program is write by labwindows cvi.
cvi code:
Qt Code:
  1. float AIdat[344];
  2. UDPWrite(writerChannel, AI_PORT, MULTICAST_ADDRESS, AIdat, sizeof(AIdat));
To copy to clipboard, switch view to plain text mode 

qt code:
Qt Code:
  1. const udpsize=1376;
  2. void Widget::processPendingDatagrams()
  3. {
  4. qint16 packetsize;
  5. while (udpSocket->hasPendingDatagrams()) {
  6. packetsize=udpSocket->pendingDatagramSize();
  7. ba.resize(packetsize);
  8. udpSocket->readDatagram(ba.data(), ba.size());
  9. if (packetsize!=udpsize)
  10. {
  11. return;
  12. }
  13. // bool ok;
  14. // ba = QByteArray::number(ba.toLongLong(&ok,16),2);
  15. QDataStream datin(&ba,QIODevice::ReadOnly);
  16. float firstdat;
  17. datin>>firstdat; //first float data
  18. if (!datin.status())
  19. {
  20. qDebug()<<"ok" ;
  21. }
  22. qDebug()<<firstdat; //it return 0 or inf;
  23. }
  24. }
To copy to clipboard, switch view to plain text mode