I'm trying to load a jpg from the resources but it fails every time. I'm checking that the file exists and can be opened, but it will not load into a pixmap. Any suggestions?
Here's the code snippet (not very subtle but each assert is a failure - it fails on line 17):
QString filename
(":/data/test.jpg");
if (!(fileInfo.exists() && fileInfo.isFile() && fileInfo.isReadable()))
Q_ASSERT(0);
{
Q_ASSERT(0);
}
else
{
file.close();
}
if (picture.isNull())
Q_ASSERT(0);
QString filename(":/data/test.jpg");
QFileInfo fileInfo(filename);
if (!(fileInfo.exists() && fileInfo.isFile() && fileInfo.isReadable()))
Q_ASSERT(0);
QFile file(filename);
if (!file.open(QIODevice::ReadOnly))
{
QString err = file.errorString();
Q_ASSERT(0);
}
else
{
file.close();
}
QPixmap picture(filename);
if (picture.isNull())
Q_ASSERT(0);
To copy to clipboard, switch view to plain text mode
Bookmarks