Qt/Mac IssuesThis file will outline known issues and possible workarounds for limitations on Mac OS X with Qt. This list will not always be complete, so please contact Trolltech support with issues you find to be missing:
GUI ApplicationsGUI Applications must be run out of a bundle (something like widgets.app/) or using the open(1) command. Mac OS X needs this to dispatch events correctly, as well as gaining access to the menubar. If using GDB you must run with the full path to the executable.
QCursorDue to Mac OS X having only 16x16 custom cursors QCursor is limited by this as well. For now the only workaround to this problem is to use a small cursor (16x16).
Anti-aliased textQt/Mac (starting with 3.0.5) has introduced some support for smooth text as suggested by Apple's Aqua Style Guildelines. This support is limited to Mac OS X >10.1.4, when this version is not detected it will fallback to the old text rendering library.
Library Support
Bundle-based LibrariesIf you want to incorporate dynamic libraries as part of your Mac OS X application bundle (the application directory), then you place these into a directory called Frameworks, a subdirectory of the application bundle. The application finds these dynamic libraries if the libraries have an install name of "@executable_path/../Frameworks/libname.dylib. If you use qmake and Makefiles, use the QMAKE_LFFLAGS_SONAME setting:
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@executable_path/../Frameworks/ In case of Project Builder, you set the Library targets to have their install path (in the Build Settings of the target) set to "@executable_path/.../Frameworks". You also need to add a custom build setting called "SKIP_INSTALL" and set this to YES. In the Application target you need to add a Copy Files build phase that will copy the library product into the applications wrapper's Framework sub-folder. Note that DYLD_LIBRARY_PATH environment variables will override these settings, same with any other default paths such as a lookup of dynamic libraries inside /usr/lib and similar default locations. We still strongly recommend to build static applications where the library code is incorporated into the Mac OS X binary. However, in case you ship applications that require plugin support,then you need to use dynamic libraries as part of your application.
Combining LibrariesIf you want to build a new dynamic library combining the Qt 3.1 dynamic libraries, you need to introduce the ld -r flag so that relocation information is stored in the the output file, so that this file could be the subject of another ld run. This is done by setting the -r flag in the .pro file, and the LFLAGS settings.
Compiler Settings
Compile-time FlagsIf you want to wrap any specific Mac OS X code in a define, use the Q_OS_MACX flag, as in:
#if defined(Q_OS_MACX) // the code used #endif Note that when you build under Mac OS X 10.2, then the MACOSX_102 flag is automatically included in the make builds.
Building and Configuring Qt/Mac
Problems building a static configurationIf a static build fails with the following error messages during the designer make phase:
QWidget::sizeHint() const referenced from libqui expected to be defined in @executable_path/../Frameworks/libqt-mt.3.dylib non-virtual thunk [nv:-40] to QWidget::metric(int) const referenced from libqui expected to be defined in @executable_path/../Frameworks/libqt-mt.3.dylib then ensure that your library path does not have libqui libraries or symbolic links. If you remove these, then the build will continue.
Macintosh Native API Access
Accessing the Bundle PathThe Macintosh application is actually a directory (ending with .app). This directory has various other sub-directories and sources. In case you want to place for example the plugin directory inside this bundle, then you need to find out where the bundle resides on the disk. The following code will do this:
CFURLRef pluginRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef, kCFURLPOSIXPathStyle); const char *pathPtr = CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding()); qDebug("Path = %s", pathPtr); Do not forget to enclosure this in an #if defined(Q_OS_MACX) macro statement.
User Interface
Right-Mouse ClicksIf you want to provide right-mouse click support for Mac OS X, use the QContextMenuEvent class. This will map to a context menu event, in other words a menu that will display a popup 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.
Menubar
Qt/Mac will automatically detect your menubars for you and turn them into Mac native menubars. Fitting this into your existing Qt application will normally be automatic, however, if you have special needs the Qt/Mac implementation currently selects a menubar by starting at the active window (ie QApplication::activeWindow()), and applying: 1) If the window has a QMenuBar then it is used. 2) If the window is a modal then its menubar is used. If no menubar is specified then a default menubar is used (as documented below) 3) If the window has no parent then the default menubar is used (as documented below). The above 3 steps are applied all the way up the parent window chain until one of the above are satisifed. If all else fails a default menubar will be created, the default menubar on Qt/Mac is an empty menubar, however you can create a different default menubar by creating a parentless QMenuBar, the first one created will thus be designated the default menubar, and will be used whenever a default menubar is needed.
Limitations
QCustomMenuItemsQCustomMenuItems are not supported in Mac native menubars, they are supported in popupmenus that are not in the Mac native menubar.
File DialogThe static functions of QFileDialog use Mac OS X's Navigation Services. Navigation Services takes care of saving the location to look for saving and opening files (storing this in $HOME/Library/Preferences/appname.plist). There appears to be no way to programmically set them. Therefore, the "startWith" variable is ignored by these functions.
Unsupported Native WidgetsQt/Mac currently has no support for sheets, drawers, or the chooser (Panther-style tabs). There may be support for these in a future version of Qt. |
Publicité
Best OfActualités les plus luesSemaine
Mois
Année
Le Qt Labs au hasardAméliorer les performances de Qt lors du rendu avec plus de SIMDLes Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.
CommunautéRessources
Liens utilesContact
Qt dans le magazine |
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 3.2 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com