johnsonwi
johnsonwi

Reputation: 159

Jpeg read errors using QImage in release builds

Has anyone experienced problems using Qt and the QImage's class load method when attempting to load jpeg images. The loading works perfectly in debug mode using QtCreator but fails completely when attempting to load the same jpeg images when the application is built and thereafter run in release mode.

QImage myImage;
QString s = QDir().toNativeSeparators(QFileDialog::getOpenFileName(this, QString("Import Image...")));
if ( !myImage.load(s) ) {
    QMessageBox msgBox;
    msgBox.setWindowTitle(this->windowTitle());
    msgBox.setWindowIcon(this->windowIcon());
    msgBox.setIcon(QMessageBox::Information);
    msgBox.setText("Image could not be loaded.");
    msgBox.exec();
    return;
}

I've concluded I may be missing a specific dynamic link library but cannot foresee which one it would be. Please note that in release mode, I am still able to process PNG images.

Upvotes: 1

Views: 1563

Answers (2)

Probably one of the dll's needed by your applications is not being found in yout PATH environment variable. You can use Dependency Walker to discover which dll's are missing.

Upvotes: 0

Aakash
Aakash

Reputation: 1900

Add the imageplugins(or imageformats) folder to your build. Using jpg requires libjpeg.dll to be available for the executable. Look under your Qt installation dir for the required files.

Upvotes: 1

Related Questions