How to located image files for MAC?
Load image is Ok.
When MAC OS
image/ < load image success. but i want this not...
app.app/Contents/MacOS/image/1.png <- don't load image
app.app/Resources/image/1.png <- don't load image
when i coding >>icon.addFile("image/1.png"~~~~~~~;
app.app/Resources/image/1.png <-- want load image..
Because When i do design form, I use the QT Designer.
Auto Create ui_mainwindow.h
this line icon.addFile("image/1.png"~~~~~~~; ...
The correct path is
app.app/Contents/Resources ... maybe with subdirs, that's up to you.
To construct a path use this snippet:
QString imageDir = QCoreApplication::applicationDirPath() + "/../Resources";
QString imageDir = QCoreApplication::applicationDirPath();
icon.addFile(imageDir + "/1.png");
But this code automatic created. -> icon.addFile("1.png");
Because I made that desing form. That code auto created..
In that case you should remove the images from the designer form and set the icons programmatically in your C++ class.
Another solution would be to put the icons into a "Qt Resource file":/doc/qt-4.8/resources.html. You can use those in "Designer:"/doc/qt-4.8/designer-resources.html as well.
Have a good week.