Qt-interest Archive, November 2003
graphics in Qt/Mac bundle
Message 1 in thread
OK, so I am successfully building my app on a Mac using Qt/Mac. I'm very
impressed with how smart qmake is about the .app Mac application bundle.
However, I have a few graphics in a graphics folder (inside the folder
with my various source files) that are used in QLabels. The graphics
aren't getting bundled inside the .app correctly. I tried just moving
them into Contents/MacOS (alongside the actual application - where they
live in the Linux version of this app) but that had no effect.
Any ideas on this?
----------
An unrelated question...
Also, my app is being compiled against /usr/lib/libresolv.9.dylib, a file
which doesn't seem to appear on another Mac I have access to, so I expect
that file to be part of the developer tools.
If I remove -lresolv from the Makefile, the app still compiles OK. Does
anybody know if/why I need this library?
Thanks,
Dave Margolis
Message 2 in thread
Hi David,
Am 09.11.2003 um 18:11 schrieb David Margolis:
> However, I have a few graphics in a graphics folder (inside the folder
> with my various source files) that are used in QLabels. The graphics
> aren't getting bundled inside the .app correctly. I tried just moving
> them into Contents/MacOS (alongside the actual application - where they
> live in the Linux version of this app) but that had no effect.
This is how I solved the problem:
I made a directory "Resources" which contain all the files I need in my
program (config files, icons, graphics, etc.).
On Windows, this Resources directory is located in the same directory
as the exe, therefore visible to the user.
On Mac, I hide this Resources directory in (obviously)
<application>.app/Contents/Resources. That way, I get the typical Mac
behaviour of having all resources inside the Program. So the user
doesn't need to worry about it and has drag&drop installation.
In my program, I locate the path to the Resources directory like this:
QString
ETPlatformIndependent::addResourcePath( const QString & filename )
{
#ifdef Q_WS_MACX
QString appName = qApp->argv()[0];
return QString( appName.left( appName.findRev('/') ) +
"/../Resources/" + filename );
#else
return QString( "Resources/" + filename );
#endif
}
(remember ths the actual running application is in
<application>.app/Contents/MacOS/<application> !)
Whenever I need to open a file, I open
ETPlatformIndependent::addResourcePath('xyz.jpg');
And for generating, well I made a simple "macmake" shellscript which
copies, after making the project, the Resources directory inside the
.app.
Herwig
--
[ signature omitted ]
Message 3 in thread
On Monday, Nov 10, 2003, at 05:15 Canada/Eastern, Herwig Henseler wrote:
> I made a directory "Resources" which contain all the files I need in
> my program (config files, icons, graphics, etc.).
>
> On Windows, this Resources directory is located in the same directory
> as the exe, therefore visible to the user.
>
> On Mac, I hide this Resources directory in (obviously)
> <application>.app/Contents/Resources. That way, I get the typical Mac
> behaviour of having all resources inside the Program. So the user
> doesn't need to worry about it and has drag&drop installation.
This is exactly the approach we use in our apps. It seems to work
pretty well, and Mac users like having their drag&drop installation.
The only difference is that we use qembed to incorporate some of the
smaller images (icons etc.) right into the application.
> #ifdef Q_WS_MACX
> QString appName = qApp->argv()[0];
> return QString( appName.left( appName.findRev('/') ) +
> "/../Resources/" + filename );
> #else
If you're using 3.2.2 or later, the Trolls added
QApplication::applicationDirPath(), so you can avoid messing with argv
directly.
> And for generating, well I made a simple "macmake" shellscript which
> copies, after making the project, the Resources directory inside the
> .app.
If you want to integrate this into the make process, you can also add a
QMAKE_POST_LINK step to do the same thing.
Good luck,
Eric Smith
Tarkvara Design Inc.
Message 4 in thread
Herwig (and Eric, who also answered my question),
Thanks for the response. I will look more into the platform independant
pre-processer directives right away.
Dave
On Mon, 10 Nov 2003, Herwig Henseler wrote:
> Hi David,
>
> Am 09.11.2003 um 18:11 schrieb David Margolis:
> > However, I have a few graphics in a graphics folder (inside the folder
> > with my various source files) that are used in QLabels. The graphics
> > aren't getting bundled inside the .app correctly. I tried just moving
> > them into Contents/MacOS (alongside the actual application - where they
> > live in the Linux version of this app) but that had no effect.
>
> This is how I solved the problem:
>
> I made a directory "Resources" which contain all the files I need in my
> program (config files, icons, graphics, etc.).
>
> On Windows, this Resources directory is located in the same directory
> as the exe, therefore visible to the user.
>
> On Mac, I hide this Resources directory in (obviously)
> <application>.app/Contents/Resources. That way, I get the typical Mac
> behaviour of having all resources inside the Program. So the user
> doesn't need to worry about it and has drag&drop installation.
>
> In my program, I locate the path to the Resources directory like this:
>
>
> QString
> ETPlatformIndependent::addResourcePath( const QString & filename )
> {
> #ifdef Q_WS_MACX
> QString appName = qApp->argv()[0];
> return QString( appName.left( appName.findRev('/') ) +
> "/../Resources/" + filename );
> #else
> return QString( "Resources/" + filename );
> #endif
> }
>
> (remember ths the actual running application is in
> <application>.app/Contents/MacOS/<application> !)
>
> Whenever I need to open a file, I open
> ETPlatformIndependent::addResourcePath('xyz.jpg');
>
> And for generating, well I made a simple "macmake" shellscript which
> copies, after making the project the Resources directory inside the
> .app.
>
> Herwig
> --
> Dr. Herwig Henseler Tel.: 0 44 35 / 388 486
> Freiberufl. Informatiker Fax.: 0 44 35 / 388 487
> Lehms 9, 26197 Großenkneten Mobil: 0173 / 2 02 98 41
> E-Mail: info@herwig-henseler.de Web: http://www.herwig-henseler.de
> "Life is a heuristic guided depth-first search without backtracking"
>
>