source: trunk/doc/html/mac-differences.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 11.9 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/mac.doc:36 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>Qt/Mac Issues</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Qt/Mac Issues</h1>
33
34
35
36<p> This file will outline known issues and possible workarounds for
37limitations on Mac OS X with Qt. This list will not always be complete, so
38please contact Trolltech support with issues you find to be missing.
39<p> See also the document <a href="qtmac-as-native.html">Qt/Mac is Mac OS X
40Native</a>.
41<p> <!-- toc -->
42<ul>
43<li><a href="#1"> GUI Applications
44</a>
45<li><a href="#2"> QCursor
46</a>
47<li><a href="#3"> Anti-aliased text
48</a>
49<li><a href="#4"> Library Support
50</a>
51<ul>
52<li><a href="#4-1"> Bundle-based Libraries
53</a>
54<li><a href="#4-2"> Combining Libraries
55</a>
56<li><a href="#4-3"> Initialization Order
57</a>
58<li><a href="#4-4"> Plugin Support
59</a>
60</ul>
61<li><a href="#5"> Compiler Settings
62</a>
63<ul>
64<li><a href="#5-1"> Compile-time Flags
65</a>
66</ul>
67<li><a href="#6"> Building and Configuring Qt/Mac
68</a>
69<ul>
70<li><a href="#6-1"> Problems building a static configuration
71</a>
72</ul>
73<li><a href="#7"> Macintosh Native API Access
74</a>
75<ul>
76<li><a href="#7-1"> Accessing the Bundle Path
77</a>
78<li><a href="#7-2"> Translating the Application Menu and native dialogs
79</a>
80</ul>
81<li><a href="#8"> User Interface
82</a>
83<ul>
84<li><a href="#8-1"> Right-Mouse Clicks
85</a>
86<li><a href="#8-2"> Menubar
87</a>
88</ul>
89<li><a href="#9"> Limitations
90</a>
91<ul>
92<li><a href="#9-1"> MenuItems
93</a>
94<li><a href="#9-2"> Unsupported Native Widgets
95</a>
96</ul>
97</ul>
98<!-- endtoc -->
99
100<p> <h2> GUI Applications
101</h2>
102<a name="1"></a><p> GUI Applications must be run out of a bundle (something like widgets.app/)
103or using the open(1) command. Mac OS X needs this to dispatch events correctly,
104as well as gaining access to the menubar. If using GDB you must run with the
105full path to the executable.
106<p> <h2> <a href="qcursor.html">QCursor</a>
107</h2>
108<a name="2"></a><p> Due to Mac OS X having only 16x16 custom cursors QCursor is limited by this
109as well. For now the only workaround to this problem is to use a small
110cursor (16x16).
111<p> <h2> Anti-aliased text
112</h2>
113<a name="3"></a><p> Qt/Mac (starting with 3.0.5) has introduced some support for smooth text as
114suggested by Apple's Aqua Style Guildelines. This support is limited to Mac
115OS X >10.1.4, when this version is not detected it will fallback to the old
116text rendering library.
117<p> <h2> Library Support
118</h2>
119<a name="4"></a><p> <h3> Bundle-based Libraries
120</h3>
121<a name="4-1"></a><p> If you want to incorporate dynamic libraries as part of your Mac OS X
122application bundle (the application directory), then you place these into a
123directory called Frameworks, a subdirectory of the application bundle.
124<p> The application finds these dynamic libraries if the libraries have an
125install name of "@executable_path/../Frameworks/libname.dylib.
126<p> If you use qmake and Makefiles, use the QMAKE_LFFLAGS_SONAME setting:
127<p> <pre>
128QMAKE_LFLAGS_SONAME = -Wl,-install_name,@executable_path/../Frameworks/
129</pre>
130
131<p> In case of Project Builder, you set the Library targets to have their
132install path (in the Build Settings of the target) set to
133"@executable_path/.../Frameworks". You also need to add a custom build
134setting called "SKIP_INSTALL" and set this to YES. In the Application
135target you need to add a Copy Files build phase that will copy the library
136product into the applications wrapper's Framework sub-folder.
137<p> Note that DYLD_LIBRARY_PATH environment variables will override these
138settings, same with any other default paths such as a lookup of dynamic
139libraries inside /usr/lib and similar default locations.
140<p> We still strongly recommend to build static applications where the library
141code is incorporated into the Mac OS X binary. However, in case you ship
142applications that require plugin support,then you need to use dynamic
143libraries as part of your application.
144<p> <h3> Combining Libraries
145</h3>
146<a name="4-2"></a><p> If you want to build a new dynamic library combining the Qt 3.1 dynamic
147libraries, you need to introduce the ld -r flag so that relocation information
148is stored in the the output file, so that this file could be the subject of
149another ld run. This is done by setting the -r flag in the .pro file, and the
150LFLAGS settings.
151<p> <h3> Initialization Order
152</h3>
153<a name="4-3"></a><p> dyld(1) will call global static initializers in the order in which
154they are linked into your application. If a library links against Qt
155and references globals in Qt (from global initializers in your own
156library) you should be sure to link against Qt before your library,
157otherwise the result will be undefined (as Qt's global initializers
158have not been called yet).
159<p> <h3> Plugin Support
160</h3>
161<a name="4-4"></a><p> Note that it is not possible to build Qt plugins using Project Builder
162or Xcode. Use <a href="qmake-manual.html">qmake</a> to configure and
163build plugins.
164<p> <h2> Compiler Settings
165</h2>
166<a name="5"></a><p> <h3> Compile-time Flags
167</h3>
168<a name="5-1"></a><p> If you want to wrap any specific Mac OS X code in a define, use the Q_OS_MACX
169flag, as in:
170<p> <pre>
171#if defined(Q_OS_MACX)
172// the code used
173#endif
174</pre>
175
176<p> Note that when you build under Mac OS X 10.2, then the MACOSX_102 flag is
177automatically included in the make builds.
178<p> <h2> Building and Configuring Qt/Mac
179</h2>
180<a name="6"></a><p> <h3> Problems building a static configuration
181</h3>
182<a name="6-1"></a><p> If a static build fails with the following error messages during the
183designer make phase:
184<p> <pre>
185QWidget::<a href="qwidget.html#sizeHint">sizeHint</a>() const referenced from libqui expected to be defined in @executable_path/../Frameworks/libqt-mt.3.dylib
186non-virtual thunk [nv:-40] to QWidget::metric(int) const referenced from libqui
187 expected to be defined in @executable_path/../Frameworks/libqt-mt.3.dylib
188</pre>
189
190<p> then ensure that your library path does not have libqui libraries or
191symbolic links. If you remove these, then the build will continue.
192<p> <h2> Macintosh Native API Access
193</h2>
194<a name="7"></a><p> <h3> Accessing the Bundle Path
195</h3>
196<a name="7-1"></a><p> The Macintosh application is actually a directory (ending with .app). This
197directory has various other sub-directories and sources. In case you want
198to place for example the plugin directory inside this bundle, then you need
199to find out where the bundle resides on the disk. The following code will
200do this:
201<p> <pre>
202 CFURLRef pluginRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
203 CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef,
204 kCFURLPOSIXPathStyle);
205 const char *pathPtr = CFStringGetCStringPtr(macPath,
206 CFStringGetSystemEncoding());
207 <a href="qapplication.html#qDebug">qDebug</a>("Path = %s", pathPtr);
208 CFRelease(pluginRef);
209 CFRelease(macPath);
210</pre>
211
212<p> Do not forget to enclosure this in an #if defined(Q_OS_MACX) macro statement.
213<p> <h3> Translating the Application Menu and native dialogs
214</h3>
215<a name="7-2"></a><p> You need to do a little extra to get the Application Menu and native dialogs
216localized. This is a requirement of Mac OS X and not of Qt.
217<p> First, you must add a localized resource folder inside the Bundle see:
218<p> http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBundles/index.html
219<p> And look for the heading: Adding Localized Resources
220<p> The main thing you need to do is create a file called locversion.plist.
221Here is an example one for Norwegian:
222<p> <pre>
223&lt;?xml version="1.0" encoding="UTF-8"?&gt;
224&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
225"http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
226&lt;plist version="1.0"&gt;
227&lt;dict&gt;
228 &lt;key&gt;LprojCompatibleVersion&lt;/key&gt;
229 &lt;string&gt;123&lt;/string&gt;
230 &lt;key&gt;LprojLocale&lt;/key&gt;
231 &lt;string&gt;no&lt;/string&gt;
232 &lt;key&gt;LprojRevisionLevel&lt;/key&gt;
233 &lt;string&gt;1&lt;/string&gt;
234 &lt;key&gt;LprojVersion&lt;/key&gt;
235 &lt;string&gt;123&lt;/string&gt;
236&lt;/dict&gt;
237&lt;/plist&gt;
238</pre>
239
240<p> Then when you run the application with your preferred language set to Norwegian
241you should see menu items like "Avslutt" instead of "Quit"
242<p> <h2> User Interface
243</h2>
244<a name="8"></a><p> <h3> Right-Mouse Clicks
245</h3>
246<a name="8-1"></a><p> If you want to provide right-mouse click support for Mac OS X, use the
247<a href="qcontextmenuevent.html">QContextMenuEvent</a> class. This will map to a context menu event, in other
248words a menu that will display a popup selection. This is the most common
249use of right-mouse clicks, and maps to a control-click with the Mac OS X
250one-button mouse support.
251<p> <h3> Menubar
252</h3>
253<a name="8-2"></a><p> Qt/Mac will automatically detect your menubars for you and turn them
254into Mac native menubars. Fitting this into your existing Qt application
255will normally be automatic, however, if you have special needs the Qt/Mac
256implementation currently selects a menubar by starting at the active window
257(ie <a href="qapplication.html#activeWindow">QApplication::activeWindow</a>()), and applying:
258<p> 1) If the window has a <a href="qmenubar.html">QMenuBar</a> then it is used.
2592) If the window is a modal then its menubar is used. If no menubar is
260specified then a default menubar is used (as documented below)
2613) If the window has no parent then the default menubar is used (as documented below).
262<p> The above 3 steps are applied all the way up the parent window chain until
263one of the above are satisifed. If all else fails a default menubar will be
264created, the default menubar on Qt/Mac is an empty menubar, however you can
265create a different default menubar by creating a parentless QMenuBar, the
266first one created will thus be designated the default menubar, and will be
267used whenever a default menubar is needed.
268<p> <h2> Limitations
269</h2>
270<a name="9"></a><p> <h3> MenuItems
271</h3>
272<a name="9-1"></a><p> <ul>
273<p> <li> QCustomMenuItems are not supported in Mac native menubars, they are supported
274in popupmenus that are not in the Mac native menubar.
275<p> <li> Items with accelerators that have more than one keystroke
276(<a href="qkeysequence.html">QKeySequence</a>) will not be honored, and the first key will be used.
277<p> </ul>
278<p> <h3> Unsupported Native Widgets
279</h3>
280<a name="9-2"></a><p> Qt/Mac 3.x has no support for sheets or drawers. Support for these types of windows is provided in Qt/Mac 4.x.
281
282<!-- eof -->
283<p><address><hr><div align=center>
284<table width=100% cellspacing=0 border=0><tr>
285<td>Copyright &copy; 2007
286<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
287<td align=right><div align=right>Qt 3.3.8</div>
288</table></div></address></body>
289</html>
Note: See TracBrowser for help on using the repository browser.