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.
fileContent.clear();
QFile file("://image.jpg");
QMessageBox::information(0,
"error",
file.
errorString());
}
qDebug() << file.bytesAvailable(); //119251 which is equal to file size
fileContent.append(wholeFile);
qDebug() << fileContent.length(); //212887 -> not equal to to file size!
// while(!in.atEnd()) {
// QString line = in.readLine();
// fileContent.append(line);
// }
file.close();
QPixmap px
(fileContent.
constData());
ui->label->setPixmap(px);
fileContent.clear();
QFile file("://image.jpg");
if(!file.open(QIODevice::ReadOnly)) {
QMessageBox::information(0, "error", file.errorString());
}
qDebug() << file.bytesAvailable(); //119251 which is equal to file size
QTextStream in(&file);
QString wholeFile = in.readAll();
fileContent.append(wholeFile);
qDebug() << fileContent.length(); //212887 -> not equal to to file size!
// while(!in.atEnd()) {
// QString line = in.readLine();
// fileContent.append(line);
// }
file.close();
QPixmap px(fileContent.constData());
ui->label->setPixmap(px);
To copy to clipboard, switch view to plain text mode
Bookmarks