I can setPixmap the contents of an image file opened via Open. file.BytesAvailable gives me a different value than the number of characters I read from file. Finally, nothing is displayed in the label background.

Qt Code:
  1. fileContent.clear();
  2.  
  3. QFile file("://image.jpg");
  4.  
  5. if(!file.open(QIODevice::ReadOnly)) {
  6.  
  7. QMessageBox::information(0, "error", file.errorString());
  8. }
  9.  
  10. qDebug() << file.bytesAvailable(); //119251 which is equal to file size
  11.  
  12. QTextStream in(&file);
  13.  
  14. QString wholeFile = in.readAll();
  15.  
  16. fileContent.append(wholeFile);
  17.  
  18. qDebug() << fileContent.length(); //212887 -> not equal to to file size!
  19.  
  20. // while(!in.atEnd()) {
  21.  
  22. // QString line = in.readLine();
  23.  
  24. // fileContent.append(line);
  25. // }
  26.  
  27. file.close();
  28.  
  29. QPixmap px(fileContent.constData());
  30.  
  31. ui->label->setPixmap(px);
To copy to clipboard, switch view to plain text mode