Qt Lib For Mac

How can I add external library into a project built by Qt Creator RC1 (version 0.9.2)? For example, the win32 function EnumProcesses requires Psapi.lib to be added in the project to build. Qt offers a deployment tool for Mac: The Mac Deployment Tool. The Mac deployment tool can be found in QTDIR/bin/macdeployqt.It is designed to automate the process of creating a deployable application bundle that contains the Qt libraries as private frameworks. Mac OS X always double buffers the screen so the Qt::WAPaintOnScreen attribute has no effect. Also it is impossible to paint outside of a paint event so Qt::WAPaintOutsidePaintEvent has no effect either. Library Support Qt libraries as frameworks. By default, Qt is built as a set of frameworks. I downloaded the Qt libraries 4.8.5 for Mac (185 MB) and debug libraries (480 MB). After installing both of them I found that Qt Creator was not bundled with the installation. I downloaded the Qt Creator 3.0.1 for Mac (62 MB) in the same downloads page. If I open Qt Creator now, I am not able to create a New Project and it says 'No Kits found'. The Mac Deployment Tool. The Mac deployment tool can be found in QTDIR/bin/macdeployqt. It is designed to automate the process of creating a deployable application bundle that contains the Qt libraries as private frameworks. The mac deployment tool also deploys the Qt plugins, according to the following rules (unless -no-plugins option is used).

Home · All Classes · All Functions · Overviews

[Previous: Installation]

Note: Qt for Mac OS X has some requirements that are given in more detail in the Qt for Mac OS X Requirements document.

Note for the binary package: If you have the binary package, simply double-click on the Qt.mpkg and follow the instructions to install Qt. You can later run the uninstall-qt.py script to uninstall the binary package. The script is located in /Developer/Tools and must be run as root.

The following instructions describe how to install Qt from the source package.

  1. If you have the commercial edition of Qt, install your license file as $HOME/.qt-license.

    For the open source version you do not need a license file.

  2. Unpack the archive if you have not done so already. For example, if you have the qt-everywhere-opensource-src-4.6.3.tar.gz package, type the following commands at a command line prompt:

    This creates the directory /tmp/qt-everywhere-opensource-src-4.6.3 containing the files from the archive.

  3. Building

    To configure the Qt library for your machine type, run the ./configure script in the package directory.

    By default, Qt is configured for installation in the /usr/local/Trolltech/Qt-4.6.3 directory, but this can be changed by using the -prefix option.

    Type ./configure -help to get a list of all available options.

    Note that you will need to specify -universal if you want to build universal binaries, and also supply a path to the -sdk option if your development machine has a PowerPC CPU. By default, Qt is built as a framework, but you can built it as a set of dynamic libraries (dylibs) by specifying the -no-framework option.

    Qt can also be configured to be built with debugging symbols. This process is described in detail in the Debugging Techniques document.

    To create the library and compile all the demos, examples, tools, and tutorials, type:

    If -prefix is outside the build directory, you need to install the library, demos, examples, tools, and tutorials in the appropriate place. To do this, type:

    as root, if neccessary (note that this requires that you have administrator access to your machine).

    There is a potential race condition when running make install with multiple jobs. It is best to only run one make job (-j1) for the install.

    Note: If you later need to reconfigure and rebuild Qt from the same location, ensure that all traces of the previous configuration are removed by entering the build directory and typing make confclean before running configure again.

  4. Environment variables

    In order to use Qt, some environment variables need to be extended.

    This is done like this:

    In .profile (if your shell is bash), add the following lines:

    In .login (in case your shell is csh or tcsh), add the following line:

    If you use a different shell, please modify your environment variables accordingly.

  5. That's all. Qt is now installed.

    If you are new to Qt, we suggest that you take a look at the demos and examples to see Qt in action. Run the Qt Examples and Demos either by typing qtdemo on the command line or through the desktop's Start menu.

    You might also want to try the following links:

We hope you will enjoy using Qt. Good luck!

Mac

[Previous: Installation]

Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)Trademarks

In this blog post we'll explore the basic steps to deploy a Qt application for macOS, including assigning an icon for the application and adding assets. It is assumed that you have Qt Creator and Qt version 5.7.1 or later installed and configured on your macOS computer. If not, this blog can be used as a reference point.

Getting Started

The first thing to understand is the structure of a macOS application. MacOS makes use of the concept of bundling. Mac applications are technically folders with .app extensions.

From a normal user's standpoint from the GUI, it is a single executable entity. But from a developer or command-line savvy user’s perspective, it is a folder with the executable and required resources, including libraries, assets and icon files.

Qmake, by default, automatically generates a bundle for the application without the project file explicitly stating this, but it is good practice to do so, i.e.

CONFIG += app_bundle # to remove, do CONFIG -= app_bundle

Icons

Before we compile and deploy, we should look at how to set the icon that is shown on the dock, desktop, and launch folder. Modify your project file to add the following line:

ICON = myIcon.icns

Where myIcons.icns is located within your project’s filetree. Qmake will automatically create the info.plist entry needed and copy the icon into the application’s resource folder (Contents/Resources).

Adding Additional Folders

If you have additional resource files you need to include with your application but that can't be put in a qrc resource file (QML files for example), you can append it to the QMAKE_BUNDLE_DATA section in your project file:

mySetOfExtraFiles.files= $$PWD/imagesFolder
mySetOfExtraFiles.path= Contents/Resources
QMAKE_BUNDLE_DATA += mySetOfExtraFiles

These three lines will tell qmake to copy the folder imagesFolder into the application’s Contents/Resources folder. If you need it to be in the same directory as the executable, you should put the path as Contents/MacOS.

Compiling and Deployment

The first step is to compile your code in release mode and prepare it to be distributable beyond your build directory.

Compiling from the terminal

Navigate to your code folder using the terminal, and compile it:

If you were able to compile successfully without any errors, you will now see that a <ApplicationName>.app folder exists in your build directory.

Compiling from Qt Creator

To compile in Qt Creator go to Build > Clean Project “ProjectName”. This is equivalent to typing make clean on the command line. In the lower left corner of the Qt Creator interface, there is a monitor like icon, click on it and select your project name, and “release” build. Go to Build > Build project “ProjectName” (equivalent to running make on the command line).

Deployment

To deploy an application you will be making use of macdeployqt, which is a deployment tool included with Qt Creator. It is commonly located at <QTDIR>/bin/macdeployqt. (You can also search for it using the command find / -iname macdeployqt.) Qt Creator does not have this deployment option integrated into its interface so you will need to use it through the command line. macdeployqt is useful when your application has primarily Qt libraries and no custom libraries. If you have custom libraries, you will need to manually copy them into the bundle after it is created.

Assuming you are in the build directory, if you have no QML files, run:

If you have QML files, instead use:

Qt Lib For Mac Download

macdeployqt <ApplicationName>.app-qmldir=<path to QMLs>

To place the bundle into a disk image for easy distribution, add -dmg to the command. You can also zip or tar the .app folder after running macdeployqt on it.

An important note about the option -qmldir=<path>: the “path” is the absolute path to the QML source files in your project folder. This is necessary for the deployment tool to parse the QML files and include the necessary Qt libraries for those QML files. This is only applicable if you have QML files in your project.

Distributing

If all went well and no fatal errors were reported, you can now test the application by doing one of the following:

  • Run the executable within the .app folder (<ApplicationName>.app/Contents/MacOS/<Application>)
  • Run the application by navigating to the build folder in Finder and double clicking on the application
  • Run the application inside the dmg or zip archive by double clicking on it in the Finder

If the application runs and does not crash, you’re ready to pass along the zip, tar, or dmg file to other macOS machines. Once the other machines receive the archive, just drag and drop the .app folder into the Applications folder and you’re all set.

If the application does crash and you were running it from the Finder, open a terminal and manually run the executable in the application. Any error messages should output to your terminal and give you an idea of what is going wrong.

Qt Lib For Mac Mojave

I hope you've found this information valuable. (If so, please share!) More of our Qt-related technical content is available here.

Qt Mac Address

References

Qt For Mac

Qt for MacOS - Deployment