PDA

View Full Version : Background image is missing after adding dlls



Lazaruspl
23rd June 2010, 09:56
Hi,
I have application and there in MainWindow I set some background image:



QPixmap bg("./images/Background.jpg");
QPalette p(palette());
p.setBrush(QPalette::Background, bg);
setAutoFillBackground(true);
setPalette(p);


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.

high_flyer
23rd June 2010, 09:59
try adding your ./images/ folder to the folder where your exe is. (but leave it in its original place as well)

Lazaruspl
24th June 2010, 12:48
I've tried, without effect. Can you give me simple code with working background?

high_flyer
24th June 2010, 13:06
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.

Lazaruspl
24th June 2010, 13:23
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:


QPixmap bg("D:/Programowanie/QtNewProjects/KsiazkaKucharska/release/images/Background.jpg");
QPalette p(palette());
p.setBrush(QPalette::Background, bg);
setAutoFillBackground(true);
setPalette(p);

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

squidge
24th June 2010, 13:56
Maybe your problem is that it can't find the jpeg plugin? Do you have plugins directory with imageformats beneath that?

Lazaruspl
24th June 2010, 15:00
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:

QApplication a(argc, argv);
I also tried to add this:


QString myPath;
myPath = "./imageformats";
a.addLibraryPath(myPath);

Without effect.

Lazaruspl
25th June 2010, 11:18
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?

squidge
25th June 2010, 12:11
Try putting them in plugins/imageformats. Ie, a sub-dir within plugins dir as I said above.

Lazaruspl
25th June 2010, 21:29
Unfortunately no effect

Lazaruspl
25th June 2010, 22:58
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.