Hello,
I'd like to convert a char array to a string so I can show it in a status label or a text edit box:
Example:
Qt Code:
  1. char temp[4] = {0x01, 0x03, 0x03, 0x04};
  2. ....
  3. statusLabel->setText(QString::fromAscii(temp, 4));
To copy to clipboard, switch view to plain text mode 
The status label should show ideally 0x01 0x02 0x03 0x04.

I'm trying to do this in the fortune client example from Qt Creator.

Qt Code:
  1. void Client::readFortune()
  2. {
  3. QDataStream in(tcpSocket);
  4. in.setVersion(QDataStream::Qt_4_3);
  5.  
  6. char temp[30];
  7. int flag = 0;
  8. char temp2[4] = {0x01, 0x02, 0x03, 0x04};
  9.  
  10. if (blockSize == 0) {
  11. if (tcpSocket->bytesAvailable() < (int)sizeof(quint16))
  12. return;
  13.  
  14. in >> blockSize;
  15. }
  16.  
  17. flag = tcpSocket->readLine(temp, 31);// i'm trying to read the receive buffer here and show it below
  18. if(flag |= -1){
  19. messageLineEdit->setText(QString::number(blockSize)); // I can see the block size, 1537
  20. statusLabel->setText(QString::fromAscii(temp2, 4));
  21. }
  22.  
  23. if (tcpSocket->bytesAvailable() < blockSize)
  24. return;
  25.  
  26. QString nextFortune;
  27. in >> nextFortune;
  28.  
  29. if (nextFortune == currentFortune) {
  30. QTimer::singleShot(0, this, SLOT(requestNewFortune()));
  31. return;
  32. }
  33.  
  34. currentFortune = nextFortune;
  35.  
  36. statusLabel->setText(currentFortune);
  37.  
  38. getFortuneButton->setEnabled(true);
  39. }
To copy to clipboard, switch view to plain text mode