Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > 5ab010e37991249ab4adaa24d6e39c6e > files > 135

qt5-qtdoc-5.1.1-2.fc18.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- mac-differences.qdoc -->
  <title>Qt for Mac OS X - Specific Issues | QtDoc 5.1</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader"></div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#gui-applications">GUI Applications</a></li>
<li class="level1"><a href="#painting">Painting</a></li>
<li class="level1"><a href="#library-support">Library Support</a></li>
<li class="level2"><a href="#qt-libraries-as-frameworks">Qt libraries as frameworks</a></li>
<li class="level2"><a href="#bundle-based-libraries">Bundle-Based Libraries</a></li>
<li class="level2"><a href="#combining-libraries">Combining Libraries</a></li>
<li class="level2"><a href="#initialization-order">Initialization Order</a></li>
<li class="level1"><a href="#compile-time-flags">Compile-Time Flags</a></li>
<li class="level1"><a href="#mac-os-x-native-api-access">Mac OS X Native API Access</a></li>
<li class="level2"><a href="#accessing-the-bundle-path">Accessing the Bundle Path</a></li>
<li class="level2"><a href="#translating-the-application-menu-and-native-dialogs">Translating the Application Menu and Native Dialogs</a></li>
<li class="level1"><a href="#user-interface">User Interface</a></li>
<li class="level2"><a href="#right-mouse-clicks">Right-Mouse Clicks</a></li>
<li class="level2"><a href="#menu-bar">Menu Bar</a></li>
<li class="level2"><a href="#special-keys">Special Keys</a></li>
<li class="level1"><a href="#limitations">Limitations</a></li>
<li class="level2"><a href="#menu-actions">Menu Actions</a></li>
<li class="level2"><a href="#native-widgets">Native Widgets</a></li>
</ul>
</div>
<h1 class="title">Qt for Mac OS X - Specific Issues</h1>
<span class="subtitle"></span>
<!-- $$$mac-differences.html-description -->
<div class="descr"> <a name="details"></a>
<p>This file outlines known issues and possible workarounds when using Qt for Mac OS X. Contact Qt's technical support team if you find additional issues which are not covered here. (See also the document <a href="qtmac-as-native.html">Qt is Mac OS X Native</a>.)</p>
<a name="gui-applications"></a>
<h2>GUI Applications</h2>
<p>Mac OS X handles most applications as &quot;bundles&quot;. A bundle is a directory structure that groups related files together (e.g&#x2e;, widgets.app/). GUI applications in particular must be run from a bundle or by using the open(1), because Mac OS X needs the bundle to dispatch events correctly, as well as for accessing the menu bar.</p>
<p>If you are using older versions of GDB you must run with the full path to the executable. Later versions allow you to pass the bundle name on the command line.</p>
<a name="painting"></a>
<h2>Painting</h2>
<p>Mac OS X always double buffers the screen so the Qt::WA_PaintOnScreen attribute has no effect. Also it is impossible to paint outside of a paint event so Qt::WA_PaintOutsidePaintEvent has no effect either.</p>
<a name="library-support"></a>
<h2>Library Support</h2>
<a name="qt-libraries-as-frameworks"></a>
<h3>Qt libraries as frameworks</h3>
<p>By default, Qt is built as a set of frameworks. Frameworks is the Mac OS X &quot;preferred&quot; way of distributing libraries. There are definite advantages to using them. See <a href="http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/index.html">Apple's Framework Programming Guide</a> for more information.</p>
<p>In general, this shouldn't be an issue because qmake takes care of the specifics for you. The <a href="http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/index.html">Framework Programming Guide</a> discusses issues to keep in mind when choosing frameworks over the more typical, dynamic libraries. However, one point to remember is: <b>Frameworks always link with &quot;release&quot; versions of libraries</b>.</p>
<p>If you actually want to use a <i>debug</i> version of a Qt framework, you must ensure that your application actually loads that debug version. This is often done by using the DYLD_IMAGE_SUFFIX environment variables, but that way often doesn't work so well. Instead, you can temporarily swap your debug and release versions, which is documented in <a href="http://developer.apple.com/technotes/tn2004/tn2124.html#SECJUSTONELIB">Apple's &quot;Debugging Magic&quot; technical note</a>.</p>
<p>If you don't want to use frameworks, simply configure Qt with <tt>-no-framework</tt>.</p>
<a name="bundle-based-libraries"></a>
<h3>Bundle-Based Libraries</h3>
<p>If you want to use some dynamic libraries in your Mac OS X application bundle (the application directory), create a subdirectory named &quot;Frameworks&quot; in the application bundle directory and place your dynamic libraries there. The application will find a dynamic library if it has the install name <i>@executable_path/../Frameworks/libname.dylib</i>.</p>
<p>If you use <tt>qmake</tt> and Makefiles, use the <tt>QMAKE_LFLAGS_SONAME</tt> setting:</p>
<pre class="cpp">QMAKE_LFLAGS_SONAME  = -Wl,-install_name,@executable_path/../Frameworks/</pre>
<p>Alternatively, you can modify the install name using the install_name_tool(1) on the command line. See its manpage for more information.</p>
<p>Note that the <tt>DYLD_LIBRARY_PATH</tt> environment variable will override these settings, and any other default paths, such as a lookup of dynamic libraries inside <tt>/usr/lib</tt> and similar default locations.</p>
<a name="combining-libraries"></a>
<h3>Combining Libraries</h3>
<p>If you want to build a new dynamic library combining the Qt 4 dynamic libraries, you need to introduce the <tt>ld -r</tt> flag. Then relocation information is stored in the output file, so that this file could be the subject of another <tt>ld</tt> run. This is done by setting the <tt>-r</tt> flag in the <tt>.pro</tt> file, and the <tt>LFLAGS</tt> settings.</p>
<a name="initialization-order"></a>
<h3>Initialization Order</h3>
<p>dyld(1) calls global static initializers in the order they are linked into your application. If a library links against Qt and references globals in Qt (from global initializers in your own library), be sure to link your application against Qt before linking it against the library. Otherwise the result will be undefined because Qt's global initializers have not been called yet.</p>
<a name="compile-time-flags"></a>
<h2>Compile-Time Flags</h2>
<p>The follewing flags are helpful when you want to define Mac OS X specific code:</p>
<ul>
<li>Q_OS_DARWIN is defined when Qt detects you are on a Darwin-based system (including the Open Source version)</li>
<li>Q_OS_MAC is defined when you are on Mac OS.</li>
<li>Q_WS_MAC is no longer defined in Qt 5.</li>
</ul>
<p>If you want to define code for specific versions of Mac OS X, use the availability macros defined in /usr/include/AvailabilityMacros.h.</p>
<p>See QSysInfo for information on runtime version checking.</p>
<a name="mac-os-x-native-api-access"></a>
<h2>Mac OS X Native API Access</h2>
<a name="accessing-the-bundle-path"></a>
<h3>Accessing the Bundle Path</h3>
<p>The Mac OS X application is actually a directory (ending with <tt>.app</tt>). This directory contains sub-directories and files. It may be useful to place items (e.g&#x2e; plugins, online-documentation, etc.) inside this bundle. You might then want to find out where the bundle resides on the disk. The following code returns the path of the application bundle:</p>
<pre class="cpp"><span class="preprocessor">#ifdef Q_WS_MAC</span>
    CFURLRef appUrlRef <span class="operator">=</span> CFBundleCopyBundleURL(CFBundleGetMainBundle());
    CFStringRef macPath <span class="operator">=</span> CFURLCopyFileSystemPath(appUrlRef<span class="operator">,</span>
                                           kCFURLPOSIXPathStyle);
    <span class="keyword">const</span> <span class="type">char</span> <span class="operator">*</span>pathPtr <span class="operator">=</span> CFStringGetCStringPtr(macPath<span class="operator">,</span>
                                           CFStringGetSystemEncoding());
    qDebug(<span class="string">&quot;Path = %s&quot;</span><span class="operator">,</span> pathPtr);
    CFRelease(appUrlRef);
    CFRelease(macPath);
<span class="preprocessor">#endif</span></pre>
<p>Note: When OS X is set to use Japanese, a bug causes this sequence to fail and return an empty string. Therefore, always test the returned string.</p>
<p>For more information about using the CFBundle API, see <a href="http://developer.apple.com/documentation/CoreFoundation/Reference/CFBundleRef/index.html">Apple's Developer Website</a>.</p>
<p>Note: QCoreApplication::applicationDirPath() can be used to determine the path of the binary within the bundle.</p>
<a name="translating-the-application-menu-and-native-dialogs"></a>
<h3>Translating the Application Menu and Native Dialogs</h3>
<p>The items in the Application Menu will be merged correctly for your localized application, but they will not show up translated until you <a href="http://developer.apple.com/library/mac/#documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW13">add a localized resource folder</a> to the application bundle. The main thing you need to do is create a file called locversion.plist. Here is an example for Norwegian:</p>
<pre class="cpp"><span class="operator">&lt;</span><span class="operator">?</span>xml version<span class="operator">=</span><span class="string">&quot;1.0&quot;</span> encoding<span class="operator">=</span><span class="string">&quot;UTF-8&quot;</span><span class="operator">?</span><span class="operator">&gt;</span>
<span class="operator">&lt;</span><span class="operator">!</span>DOCTYPE plist PUBLIC <span class="string">&quot;-//Apple Computer//DTD PLIST 1.0//EN&quot;</span>
<span class="string">&quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;</span><span class="operator">&gt;</span>
<span class="operator">&lt;</span>plist version<span class="operator">=</span><span class="string">&quot;1.0&quot;</span><span class="operator">&gt;</span>
<span class="operator">&lt;</span>dict<span class="operator">&gt;</span>
    <span class="operator">&lt;</span>key<span class="operator">&gt;</span>LprojCompatibleVersion<span class="operator">&lt;</span><span class="operator">/</span>key<span class="operator">&gt;</span>
    <span class="operator">&lt;</span>string<span class="operator">&gt;</span><span class="number">123</span><span class="operator">&lt;</span><span class="operator">/</span>string<span class="operator">&gt;</span>
    <span class="operator">&lt;</span>key<span class="operator">&gt;</span>LprojLocale<span class="operator">&lt;</span><span class="operator">/</span>key<span class="operator">&gt;</span>
    <span class="operator">&lt;</span>string<span class="operator">&gt;</span>no<span class="operator">&lt;</span><span class="operator">/</span>string<span class="operator">&gt;</span>
    <span class="operator">&lt;</span>key<span class="operator">&gt;</span>LprojRevisionLevel<span class="operator">&lt;</span><span class="operator">/</span>key<span class="operator">&gt;</span>
    <span class="operator">&lt;</span>string<span class="operator">&gt;</span><span class="number">1</span><span class="operator">&lt;</span><span class="operator">/</span>string<span class="operator">&gt;</span>
    <span class="operator">&lt;</span>key<span class="operator">&gt;</span>LprojVersion<span class="operator">&lt;</span><span class="operator">/</span>key<span class="operator">&gt;</span>
    <span class="operator">&lt;</span>string<span class="operator">&gt;</span><span class="number">123</span><span class="operator">&lt;</span><span class="operator">/</span>string<span class="operator">&gt;</span>
<span class="operator">&lt;</span><span class="operator">/</span>dict<span class="operator">&gt;</span>
<span class="operator">&lt;</span><span class="operator">/</span>plist<span class="operator">&gt;</span></pre>
<p>Now when you run the application with your preferred language set to Norwegian, you should see menu items like &quot;Avslutt&quot; instead of &quot;Quit&quot;.</p>
<a name="user-interface"></a>
<h2>User Interface</h2>
<a name="right-mouse-clicks"></a>
<h3>Right-Mouse Clicks</h3>
<p>If you want to provide right-mouse click support for Mac OS X, use the QContextMenuEvent class. This will map to a context menu event, i.e&#x2e;, a menu that will display a pop-up selection. This is the most common use of right-mouse clicks, and maps to a control-click with the Mac OS X one-button mouse support.</p>
<a name="menu-bar"></a>
<h3>Menu Bar</h3>
<p>Qt will automatically detect your menu bars for you and turn them into Mac native menu bars. Fitting this into your existing Qt application will normally be automatic. However, if you have special needs, the Qt implementation currently selects a menu bar by starting at the active window (i.e&#x2e; QGuiApplication::focusWindow()) and applying the following tests:</p>
<ol class="1">
<li>If the window has a QMenuBar, then it is used.</li>
<li>If the window is modal, then its menu bar is used. If no menu bar is specified, then a default menu bar is used (as documented below).</li>
<li>If the window has no parent, then the default menu bar is used (as documented below).</li>
</ol>
<p>These tests are followed all the way up the parent window chain until one of the above rules is satisifed. If all else fails, a default menu bar will be created. Note the default menu bar on Qt is an empty menu bar. However, you can create a different default menu bar by creating a parentless QMenuBar. The first one created will be designated the default menu bar and will be used whenever a default menu bar is needed.</p>
<p>Note that using native menu bars introduces certain limitations on Qt classes. See the <a href="#limitations">list of limitations</a> below for more information about these.</p>
<a name="special-keys"></a>
<h3>Special Keys</h3>
<p>To provide the expected behavior for Qt applications on Mac OS X, the Qt::Meta, Qt::MetaModifier, and Qt::META enum values correspond to the Control keys on the standard Macintosh keyboard, and the Qt::Control, Qt::ControlModifier, and Qt::CTRL enum values correspond to the Command keys.</p>
<a name="limitations"></a>
<h2>Limitations</h2>
<a name="menu-actions"></a>
<h3>Menu Actions</h3>
<ul>
<li>Actions in a QMenu with accelerators that have more than one keystroke (QKeySequence) will not display correctly, when the QMenu is translated into a Mac native menu bar. The first key will be displayed. However, the shortcut will still be activated as on all other platforms.</li>
<li>QMenu objects used in the native menu bar are not able to handle Qt events via the normal event handlers. Install a delegate on the menu itself to be notified of these changes. Alternatively, consider using the QMenu::aboutToShow() and QMenu::aboutToHide() signals to keep track of menu visibility; these provide a solution that should work on all platforms supported by Qt.</li>
</ul>
<a name="native-widgets"></a>
<h3>Native Widgets</h3>
<p>Qt has support for sheets, represented in the window flag by Qt::Sheet.</p>
</div>
<!-- @@@mac-differences.html -->
</div>
</div>
</div>
<div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2013 Digia Plc and/or its
      subsidiaries. Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      The documentation provided herein is licensed under the terms of the
      <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
      License version 1.3</a> as published by the Free Software Foundation.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      Digia, Qt and their respective logos are trademarks of Digia Plc 
      in Finland and/or other countries worldwide. All other trademarks are property
      of their respective owners. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>