PDA

View Full Version : QFileInfo::absolutePath: Constructed with empty filename I can't see my image



ariad
29th September 2014, 11:10
Hello,
I'm use Qt Creator and Qt4.
i want to put an image like a icon but i can't see it, and at runtime, I have the following error message:

QFileInfo::absolutePath: Constructed with empty filename.

The image is in my .pro

Any idea? thanks

anda_skoa
29th September 2014, 12:06
Having the image in OTHER_FILES of the pro file just makes them appear in QtCreator and other IDEs that understand qmake pro files.

If you want the image to be available independent of path of the application, put the in a Qt resource.

Cheers,
_

ariad
29th September 2014, 12:39
I think than you want to tell me than I have put in my resource, and yes I did it.



QFile filename("images/foto.ico");
if(filename.exists())
qDebug("file exists");
else
qDebug("file not exists");

GeoDataIconStyle icon;
icon.setIconPath("images/foto.ico");


At runtime:
file exists
libpng warning: iCCP: profile 'ICC Profile': 1000000h: invalid rendering intent
QFileInfo::absolutePath: Constructed with empty filename

anda_skoa
29th September 2014, 13:26
I think than you want to tell me than I have put in my resource, and yes I did it.

Ah, good.
Any reason you are not accessing the file in the resource but the file on disk instead?

Cheers,
_

ariad
29th September 2014, 13:56
Yes, the image is on the disk in the folder of my project, I have a folder with the images and I have put a QDebug to check that the file exists and if you see my resource and answer at runtime the application finds the image but also tell me that QFileInfo::absolutePath: Constructed with empty filename...

I don't know what I can do...

thanks

anda_skoa
29th September 2014, 14:17
You obviously do not access the file from a resource, but yes, at least it does seem to exist on disk.

All code that you have posted looks ok. But the warning could come from GeoDataIconStyle::setIconPath() or elsewhere.

Cheers,
_

ariad
29th September 2014, 14:24
If I run in Qt creator the answer of QDebug is "file no exists" but if I run on the terminal "file exists"

Maybe that tells you something...

Thanks

anda_skoa
29th September 2014, 14:51
Most likely a different working directory of the process.

Which is why a resource would be handy, since that puts the icon data into the executable.

Cheers,
_