Results 1 to 12 of 12

Thread: Deploying Qt Application on Windows - Load JPG Images Problem

  1. #1
    Join Date
    Nov 2010
    Posts
    10
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Deploying Qt Application on Windows - Load JPG Images Problem

    Hi folks,

    Basic Description:
    I made Qt application that loads BMP, JPG, PNG... files. It works perfectly on PC with installed QtSDK.

    Problem:
    When I deploy it to PC without installed QtSDK (by deploying I mean only copying exe file and some dll files to the same folder) then problems occure.
    The application can still load BMP and PNG files, but can not load JPG files.

    Code:
    Qt Code:
    1. void Widget::OpenImage()
    2. {
    3. QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath());
    4.  
    5. if (!fileName.isEmpty())
    6. {
    7. QPixmap pixmapP(fileName); //HERE IS THE PROBLEM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    8.  
    9. if (pixmapP.isNull())
    10. {
    11. QMessageBox::information(this, tr("Image Viewer"), tr("Cannot load %1.").arg(fileName));
    12. return;
    13. }
    14.  
    15. m_pixmapImage = pixmapP;
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 

    Question:
    Can anyone give me some directions how to deploy Qt application that loads JPG files?
    I visited http://doc.qt.nokia.com/latest/deployment-windows.html but it wasn't helpful for me (configure command not recognized in Qt command prompt).

    Notes:
    I have attached my complete source code and print screens that show the structure of my "deploy" folder
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Deploying Qt Application on Windows - Load JPG Images Problem

    qjpeg4.dll should be placed in plugins/imageformats directory (watch for typos).

  3. The following user says thank you to stampede for this useful post:

    Aleksandar (16th July 2011)

  4. #3
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Deploying Qt Application on Windows - Load JPG Images Problem

    ~ We are nothing in this universe ~

  5. The following user says thank you to viulskiez for this useful post:

    Aleksandar (16th July 2011)

  6. #4
    Join Date
    Nov 2010
    Posts
    10
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Deploying Qt Application on Windows - Load JPG Images Problem

    Thanks stampede,
    qjpeg4.dll was in the folder: debug\plugins\imageformats
    and in the folder debug\imageformats (just in case)
    You were right that I should watch for typos (there was an error). I fixed it but it still didn't work.

  7. #5
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Deploying Qt Application on Windows - Load JPG Images Problem

    Ok, and what about viulskiez hint:
    And don't forget to call QApplication::addLibraryPath() or QApplication::setLibraryPaths().
    ?

  8. The following user says thank you to stampede for this useful post:

    Aleksandar (19th July 2011)

  9. #6
    Join Date
    Nov 2010
    Posts
    10
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Deploying Qt Application on Windows - Load JPG Images Problem

    Thanks viulskiez,
    I added to code what You said, but it's still acting the same way!
    Perhaps I should add some code to .pro file:
    Qt Code:
    1. QT += core gui
    2.  
    3. TARGET = TestLoadPicture
    4. TEMPLATE = app
    5.  
    6.  
    7. SOURCES += main.cpp\
    8. widget.cpp
    9.  
    10. HEADERS += widget.h
    11.  
    12. FORMS += widget.ui
    To copy to clipboard, switch view to plain text mode 

    Hi stampede,
    I was writing response to viulskiez while You were writing new message.
    I added QApplication::addLibraryPath() or QApplication::setLibraryPaths() to main function. Still the same.

  10. #7
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Deploying Qt Application on Windows - Load JPG Images Problem

    Can you show the code ? Calling qApp->addLibraryPath("<path>/plugins"); should be enough.

  11. The following user says thank you to stampede for this useful post:

    Aleksandar (19th July 2011)

  12. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Deploying Qt Application on Windows - Load JPG Images Problem

    In your first screen shot the "plugins" directory is actually named "plagins".

    You should dispense with the "plugins" directory and place all the image format plugins in a single "imageformats" subdirectory in the directory holding your application. The application should just find the plugins without any extra configuration or code on your part (this is how I deploy my app). Also make sure the plugins are from the exact same version of Qt that your application is built with (and not the plugins from the Qt Creator directory by mistake for example).

  13. The following user says thank you to ChrisW67 for this useful post:

    Aleksandar (19th July 2011)

  14. #9
    Join Date
    Nov 2010
    Posts
    10
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Deploying Qt Application on Windows - Load JPG Images Problem

    Problem solved! Thank You all!

    stampede, I'm showing You the code You asked for:
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "widget.h"
    3.  
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8. a.addLibraryPath(":/plugins/imageformats");
    9.  
    10. Widget w;
    11. w.show();
    12.  
    13. return a.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 

    ChrisW67, I noticed typing error "plagins" instead of plugins the first time stampede adviced me to "watch for typos". That was not the problem. But, You were right that I should put imageformats folder directly into folder that contains *.exe file. You were also right that I should check the source of imageformats .dll files! When I did these two things the problem was solved!

    In case anybody face similar problem, here is advice:
    NEVER COPY imageformats dll files from this folder:
    c:\QtSDK\QtCreator\bin\imageformats\

    ALWAYS COPY imageformats dll files from this folder: c:\QtSDK\Desktop\Qt\4.7.3\mingw\plugins\imageforma ts\



    Thank You all again, You were a great help to me!

  15. #10
    Join Date
    Oct 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Deploying Qt Application on Windows - Load JPG Images Problem

    Hello to all of you.

    I have a similar problem, i'm using QWebWidget, that doensn't display the images. The last post form Aleksandar said to use the imageformat *.dlls from "c:\QtSDK\Desktop\Qt\4.7.3\mingw\plugins\imageform a ts\"

    The problem i have with this statement, is, that i do not have that folder within the mingw directory. All solutions i have are stored in:

    "C:\Qt\2010.05\qt\src\plugins" (but there is only the source and no *.dll files)

    "C:\Qt\2010.05\qt\plugins"

    "C:\Qt\2010.05\bin"

    At the moment i use the third version in the bin directory. I tried both *.dll containing folders without success.
    I'm using Windows7 with QT 4.7.0 on development pc and WindowsXP in VM for testing.

    ... fixed had to use... "C:\Qt\2010.05\qt\plugins" and had writing error

  16. #11
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Deploying Qt Application on Windows - Load JPG Images Problem

    To clarify this for the next person with a Me Too post...

    The point of Aleksandar's post is that the SDK contains two sets of Qt components:
    • The set deployed with the pre-built Qt Creator in QtSDK\bin.
    • The Qt libraries, their may be several sets, that your application is built with and uses to run itself.

    You want to deploy the libraries and plugins from the Qt libraries used to build your application, not those shipped to support Qt Creator.

  17. #12
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Deploying Qt Application on Windows - Load JPG Images Problem

    Go for static build instead copying all the dlls.

    1. Install QtSDK (2009.05)

    2. Open your mkspecswin32-g++qmake.conf file (located in C:\Qt\2009.05\qt\mkspecs\win32-g++\qmake.conf) in an editor like notepad.

    3. Find the line that starts with "QMAKE_LFLAGS = -enable-stdcall-fixup..." and ddd the phrase "-static" (without quotes) after the "=" sign and before the "-enable..." phrase, so it looks like:
    QMAKE_LFLAGS = -static -enable-stdcall...

    4. Save and close this file.

    5. Set your environment variables. Right-click Computer >> Properties >> Advanced System Settings >> Click the "Environment Variables..." button.

    6. Under "User variables," make sure QTDIR is set to your Qt path (C:\Qt\2009.05\qt). Make sure QMAKESPEC is set to win32-g++.

    7. Under "System variables," edit the one called "Path." Add a semicolon ( ; ) to the end, and add the following:
    C:\Qt\2009.05\mingw\lib;C:\Qt\2009.05\mingw\bin;C: \Qt\2009.05\qt\bin

    8. When finished, relog or reboot.

    9. Open a command prompt.

    10. Change to your Qt directory by entering: cd C:\Qt\2009.05\qt

    11. Enter the following: configure -static -no-phonon -no-phonon-backend -release -no-exceptions

    12. When it asks which edition you want to use, enter "o" for open source.

    13. When it asks you to accept the terms of the license, enter "y" for yes. This will take around maybe 10 minutes to complete.

    14. When that finishes, enter the following: mingw32-make sub-src (or) nmake sub-src

    15. Go out to dinner, this will take a while (took between 1-2 hours for me).

    16. When this finishes, open your project in the Qt Creator.

    17. Double-click the project (.pro) file to open it in edit mode.

    18. Add the following line: CONFIG += static

    19. qmake Hello.pro
    nmake release (or) mingw32-make release

    20. Navigate to your release directory and voila! Your standalone executable should be there.

Similar Threads

  1. Problem deploying qt application using qsqlite on Windows XP/7
    By anoraxis in forum Installation and Deployment
    Replies: 4
    Last Post: 8th April 2011, 13:18
  2. Problem deploying a two library + executable application to windows
    By joseprl89 in forum Installation and Deployment
    Replies: 8
    Last Post: 15th March 2011, 20:52
  3. Deploying an application on windows
    By dmcr in forum Installation and Deployment
    Replies: 1
    Last Post: 23rd September 2009, 09:23
  4. problem with deploying static application in windows
    By remy06 in forum Installation and Deployment
    Replies: 3
    Last Post: 2nd June 2009, 06:46
  5. Deploying debug Qt application - failed to load ODBC driver
    By sureshbabu in forum Installation and Deployment
    Replies: 1
    Last Post: 1st November 2007, 12:35

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.