Well, the value of QLcdNumber is set using the display() property. For the first time dealing with QLcdNumber shows a strange behavior.
Consider this example:
Qt Code:
  1. void MainWindow::dataFromUdp(QByteArray pack)
  2. {
  3. if(pack.at(0) == '!')
  4. {
  5. unsigned long x;
  6.  
  7. x = (unsigned char)pack[pack.length() -1] +
  8. (unsigned char)pack[pack.length() -2] * 256 +
  9. (unsigned char)pack[pack.length() -3] * 256 * 256 +
  10. (unsigned char)pack[pack.length() -4] * 256 * 256 * 256;
  11.  
  12. //extract packet
  13.  
  14. if(x == crcCalculate(0, pack.length() - 4, pack))
  15. {
  16. //CRC is correct
  17.  
  18. if(pack[1] == 0x0d)
  19. {
  20. number = 0; // class member variable
  21. char value[6];
  22. sprintf(value,"%c%c%c%c%c", (char)pack[2],(char)pack[3],(char)pack[4],
  23. (char)pack[5],(char)pack[6]);
  24.  
  25. //Now value = 00125
  26.  
  27. number = atoi(value)/1000.0;
  28.  
  29. //Now value is 0.125
  30.  
  31. ui->lcd_range->display(number);
  32.  
  33. qDebug() << number;
  34.  
  35. //Here number and qlcd are set to -3.6xx
To copy to clipboard, switch view to plain text mode 

it's strange!