Results 1 to 11 of 11

Thread: Background image is missing after adding dlls

  1. #1
    Join Date
    Jun 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Background image is missing after adding dlls

    Hi,
    I have application and there in MainWindow I set some background image:

    Qt Code:
    1. QPixmap bg("./images/Background.jpg");
    2. QPalette p(palette());
    3. p.setBrush(QPalette::Background, bg);
    4. setAutoFillBackground(true);
    5. setPalette(p);
    To copy to clipboard, switch view to plain text mode 

    I can also do that using styles, and I can also do that using resource files. But in all those cases there is a problem. When I start application from Qt creator everything is ok. It is displaying image in background without a problem. But when I add those dlls to application folder:
    mingwm10.dll
    QtCore4.dll
    QtGui4.dll
    and I start application, background image is missing. My window icon is also not working while it was ok when I run app from Qt creator without those dlls.
    I've tried adding image formats dlls to folder but unfortunately without effect. I've also tried adding them to \imageformats\ folder witch I created in application folder.

    Maybe I do something wrong, I don't know. I would appreciate if someone could give me simple app, just MainWindow without anything other, that has got image background, witch is loaded in constructor and is working. Then I would compare code of that application with mine and maybe that could help.

    I'm using Qt Creator 1.2.1 Based on Qt 4.5.2 (32 bit). My OS is Windows 7 professional 64bit. But the same problem I had on Vista 32bit.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Background image is missing after adding dlls

    try adding your ./images/ folder to the folder where your exe is. (but leave it in its original place as well)
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jun 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Background image is missing after adding dlls

    I've tried, without effect. Can you give me simple code with working background?

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Background image is missing after adding dlls

    you wrote that the code works if you start it in the IDE,so its not a code problem.
    Its very likely a path problem.
    Put absolute path instead of the relative and see if it works then.
    I would recommend to use a resources file (qrc), it makes resource management much simpler.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Jun 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Background image is missing after adding dlls

    Hmmm I've tried putting absolute path, but it's not working. I'll show you what happens:
    Starting from IDE without dlls in folder:
    http://i47.tinypic.com/333hksj.jpg
    Background was added like I post in the beggining. I just change path to absolute path:
    Qt Code:
    1. QPixmap bg("D:/Programowanie/QtNewProjects/KsiazkaKucharska/release/images/Background.jpg");
    2. QPalette p(palette());
    3. p.setBrush(QPalette::Background, bg);
    4. setAutoFillBackground(true);
    5. setPalette(p);
    To copy to clipboard, switch view to plain text mode 
    The same effect is when I delete this code above and load image from resource file.

    Now starting from IDE with dlls in folder, and loading image from absolute path:
    http://i45.tinypic.com/2qc3riu.jpg

    Now starting from IDE with dlls in folder, and loading image from resource file:
    http://i48.tinypic.com/1177fdg.jpg

  6. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Background image is missing after adding dlls

    Maybe your problem is that it can't find the jpeg plugin? Do you have plugins directory with imageformats beneath that?

  7. #7
    Join Date
    Jun 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Background image is missing after adding dlls

    In application folder I add folder named imageformats, and there I add files:
    qgif4.dll
    qico4.dll
    qjpeg4.dll
    qmng4.dll
    qsvg4.dll
    qtiff4.dll

    Is that what you are talking about?

    In function "main" uder line:
    Qt Code:
    1. QApplication a(argc, argv);
    To copy to clipboard, switch view to plain text mode 
    I also tried to add this:
    Qt Code:
    1. QString myPath;
    2. myPath = "./imageformats";
    3. a.addLibraryPath(myPath);
    To copy to clipboard, switch view to plain text mode 
    Without effect.

  8. #8
    Join Date
    Jun 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Background image is missing after adding dlls

    I think I know what is going on. When I start application having dlls in folder I can't delete them becouse application is using them, however I can delete image dlls when program is running so it's probably not loading them. How can I force application to load those image dlls?

  9. #9
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Background image is missing after adding dlls

    Try putting them in plugins/imageformats. Ie, a sub-dir within plugins dir as I said above.

  10. #10
    Join Date
    Jun 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Background image is missing after adding dlls

    Unfortunately no effect

  11. #11
    Join Date
    Jun 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Background image is missing after adding dlls

    I know what's the problem:
    QImageReader::supportedImageFormats () returns: bmp gif ico jpeg jpg mng pbm pgm png ppm svg tif tiff xbm xpm
    While app is run without dlls. And bmp pbm pgm png ppm xbm xpm, when I run application with dlls.
    Those formats f.e. png are good with and without dlls and I finally have my background. But does anybody know why I have problems with others? I would like to have program icon, and without ico format it's hard.

Similar Threads

  1. Adding Image to QPushButton
    By Seema Rao in forum Qt Programming
    Replies: 3
    Last Post: 18th November 2011, 09:06
  2. Application won't run - missing DLLs?
    By N3wb in forum Qt Programming
    Replies: 2
    Last Post: 21st September 2009, 22:52
  3. Adding image in background
    By A.H.M. Mahfuzur Rahman in forum Qt Programming
    Replies: 6
    Last Post: 9th August 2009, 16:39
  4. missing image with zoom (QGraphicsView)
    By avis_phoenix in forum Qt Programming
    Replies: 7
    Last Post: 18th March 2009, 13:09
  5. No Background Image on Example
    By igor in forum Qt Programming
    Replies: 3
    Last Post: 19th January 2007, 12:41

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
  •  
Qt is a trademark of The Qt Company.