Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Qt 6 fails to load jpg in to QImage
Forum Update on Monday, May 27th 2025

Qt 6 fails to load jpg in to QImage

Scheduled Pinned Locked Moved Solved Qt 6
qimage
6 Posts 3 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dariusz
    wrote on last edited by Dariusz
    #1

    Hey

    I noticed that quite a few people have issues with that. I haven't found any solution, but this does not work >

        auto browse = QFileDialog(this);
        browse.setFileMode(QFileDialog::ExistingFile);
        browse.setViewMode(QFileDialog::Detail);
        auto opt = browse.exec();
        if (opt) {
            auto filePath = browse.selectedFiles()[0];
            auto fileInfo = QFileInfo(filePath);
            auto image = QImage();
            image.load(filePath,fileInfo.suffix().toStdString().c_str());
            if(!image.isNull()){
                if(image.width()>512 || image.height()>512){
                     image = image.scaled(512,512,Qt::KeepAspectRatio);
                }
                mUserImage=image;
                auto small = image.scaled(200,200,Qt::KeepAspectRatio);
                ui->mUser_userImage->setPixmap(QPixmap::fromImage(small));
            }
        }
    

    Image :
    11f7dbf4-8c8f-4508-bdda-4003585ff4bf-image.png
    JPG does not load, however PNG does.

    Win10x64
    Qt 6.2.1
    Cmake

    Has any1 found a fix for this? I saw posts on https://bugreports.qt.io/browse/QTBUG-47476 and also one more with EXIF data that are now "fixed" but still fail. PNG appear to work just fine.

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #4

      As I said - make sure the Qt jpeg plugin is there and gets loaded.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      D 1 Reply Last reply
      1
      • Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @Dariusz said in Qt 6 fails to load jpg in to QImage:

        JPG does not load, however PNG does.

        How did you install Qt? Does it also not work on your development machine? Make sure the Qt jpeg plugin is available and loaded.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        D 1 Reply Last reply
        2
        • Christian EhrlicherC Christian Ehrlicher

          @Dariusz said in Qt 6 fails to load jpg in to QImage:

          JPG does not load, however PNG does.

          How did you install Qt? Does it also not work on your development machine? Make sure the Qt jpeg plugin is available and loaded.

          D Offline
          D Offline
          Dariusz
          wrote on last edited by
          #3

          @Christian-Ehrlicher Using Qt setup app. I did not build anything custom. Used installer from website & run it all. However I did make CMAKE project myself, do I need to include anything special there?

          More or less cmake config :

          set(QT_VERSION 6)
          set(REQUIRED_LIBS Core Widgets Gui Network OpenGL Concurrent OpenGLWidgets)
          set(REQUIRED_LIBS_QUALIFIED_QT Qt6::Core Qt6::Widgets Qt6::Gui Qt6::Network Qt6::OpenGL Qt6::Concurrent Qt6::OpenGLWidgets)
          find_package(Qt${QT_VERSION} COMPONENTS ${REQUIRED_LIBS} REQUIRED)
          ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
          ADD_DEFINITIONS(${QT_DEFINITIONS} -DQT_MESSAGELOGCONTEXT)
          ADD_DEFINITIONS(-D_USE_MATH_DEFINES)
          
          1 Reply Last reply
          0
          • Christian EhrlicherC Online
            Christian EhrlicherC Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            As I said - make sure the Qt jpeg plugin is there and gets loaded.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            D 1 Reply Last reply
            1
            • Christian EhrlicherC Christian Ehrlicher

              As I said - make sure the Qt jpeg plugin is there and gets loaded.

              D Offline
              D Offline
              Dariusz
              wrote on last edited by Dariusz
              #5

              @Christian-Ehrlicher said in Qt 6 fails to load jpg in to QImage:

              As I said - make sure the Qt jpeg plugin is there and gets loaded.

              Do you know whats the name of plugin or dll? I did a run with the environment variable but all I got is widows dll print and some qfactory stuff. Nothing on jpg/missing plugins.
              Where can I find the plugi nI need?

              Wops I copied all plugins dir from QT to my project & stuff started to work, thank you!

              JKSHJ 1 Reply Last reply
              0
              • D Dariusz

                @Christian-Ehrlicher said in Qt 6 fails to load jpg in to QImage:

                As I said - make sure the Qt jpeg plugin is there and gets loaded.

                Do you know whats the name of plugin or dll? I did a run with the environment variable but all I got is widows dll print and some qfactory stuff. Nothing on jpg/missing plugins.
                Where can I find the plugi nI need?

                Wops I copied all plugins dir from QT to my project & stuff started to work, thank you!

                JKSHJ Online
                JKSHJ Online
                JKSH
                Moderators
                wrote on last edited by
                #6

                @Dariusz said in Qt 6 fails to load jpg in to QImage:

                Do you know whats the name of plugin or dll?

                imageformats\qjpeg.dll

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                2

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved