Run Qt App On Mac

You can download the Qt 5 installers from the Downloads page. For more information, see Getting Started with Qt. Before installing Qt, you first need to install Xcode. You will find it in the Mac App Store here. Note: As recommended by Apple, you should always use the latest Xcode version when building your applications for the App Store. In practice this means you also need the latest version of macOS to develop apps with Qt, due to Xcode's system requirements.

Introduction

What is a URL Scheme or Plugin Protocol?

When you write a web address it starts with 'http:' or 'https:'. An FTP connection (within a browser) starts 'ftp:' that part of the address is known as the 'scheme'.

Many applications create their own schemes so that data can be passed from the browser via an <a href='anewscheme:this_data_is_sent_to_the_native_application'> style link.

I went through the mill getting this to work (especially on the Mac). By comparison Windows is very simple to setup - just a few registry hacks. So, let's start there.

Windows

All one needs to do to in Windows is set the appropriate registry keys. Let's assume that we've installed our application at 'C:Program FilesAcmeMyAcmeProgram.exe'

We need to add the following keys to the registry, all in HKEY Class Root. I instruct NSIS to do this at installation time as it knows where the application is to be installed.

NOTE, the 'URL Protocol' key really is empty. It's simply a place marker
NOTE, the extra quotes around the %1 are essential especially if your URL contains commas, spaces or any other character that specifies a parameter separator on the command line.

Operation

When the user accesses a link with like 'anewscheme:datagoeshere' the application is executed and the link itself is sent to the application as argv[1]. It's that simple. You may want to make your application single instance and pipe the given URL to the first instance of the application.


Mac Os X

For the Mac we have much more work to do. The first thing we will need to do is to install an AppleEvent handler in our 'main' function like this...


We also need to provide the function 'macCallbackGetUrl'

Download

NOTE:'app' is whatever you want. Possibly the most convenient object to pass to the event handler is your QApplication derived application class.

We're NEARLY there! The very last thing we need to do is to invoke the Carbon event loop. However, Qt does this for you when you create a QApplication object (which you did in main just after setting up the Apple event handler right?)

To make this all compile and link properly we need to link against the Carbon framework. TO do this we need to add one extra line to our qmake .pro file when building for the Mac

To finish off we need to add some XML to Info.plist which is inside the app bundle. Use finder to open the package and in the 'Contents' folder you'll find 'Info.plist' - you can use the property edit to edit this - just double click.

However! There's a little trick you can use in your qmake .pro (or .pri) file. Qt installs a very minimal Info.plist in your app bundle. To override this and provide your own add the line

Another way to do this is to use 'install' type 'man install' for more info. This lets you add/delete files from a package at will and is very powerful.

Anyhoo. These are the keys that need adding...

Operation

When the user access a 'anewscheme:' URL an Apple Event is received in the callback function and we can pick out that data and process it anyway we like.

Epilogue

And that's all! Honest! L8rz, burnttoy

Native Mac apps built with Mac Catalyst can share code with your iPad apps, and you can add more features just for Mac. In macOS Big Sur, you can create even more powerful versions of your apps and take advantage of every pixel on the screen by running them at native Mac resolution. Apps built with Mac Catalyst can now be fully controlled using just the keyboard, access more iOS frameworks, and take advantage of the all-new look of macOS Big Sur. There’s never been a better time to turn your iPad app into a powerful Mac app.

Qt App

Designed for macOS Big Sur.

When an app built with Mac Catalyst runs on macOS Big Sur, it automatically adopts the new design. The new Maps and Messages apps were built with the latest version of Mac Catalyst.

Run Qt App On Macbook

Get a head start on your native Mac app.

Your iPad app can be made into an excellent Mac app. Now’s the perfect time to bring your app to life on Mac. The latest version of Xcode 12 is all you need. Begin by selecting the “Mac” checkbox in the project settings of your existing iPad app to create a native Mac app that you can enhance further. Your Mac and iPad apps share the same project and source code, making it easy to make changes in one place.

Optimize your interface for Mac.

Your newly created Mac app runs natively, utilizing the same frameworks, resources, and runtime environment as apps built just for Mac. Fundamental Mac desktop and windowing features are added, and touch controls are adapted to the keyboard and mouse. By default, your app will scale to match the iPad’s resolution. On macOS Big Sur, you can choose “Optimize interface for Mac” to use the Mac idiom, running your app using the native resolution on Mac. This gives you full control of every pixel on the screen and allows your app to adopt more controls specific to Mac, such as pull-down menus and checkboxes.

Even more powerful.

The new APIs and behaviors in macOS Big Sur let you create even more powerful Mac apps. Apps can now be fully controlled using just the keyboard. You can create out-of-window and detachable popovers, control window tabbing using new window APIs, and make it easier for users to select photos in your app by using the updated Photos picker. iOS Photos editing extensions can now be built to run on Mac. And your app is even easier to manage when it’s running in the background with improved app lifecycle APIs.

New and updated frameworks.

Mac Catalyst adds support for new and updated frameworks to extend what your apps can do on Mac. HomeKit support means home automation apps can run alongside the Home app on Mac. The addition of the ClassKit framework lets Mac apps track assignments and share progress with teachers and students. Plus, there are updates to many existing frameworks, including Accounts, Contacts, Core Audio, GameKit, MediaPlayer, PassKit, and StoreKit.

Tools and resources.

Download Xcode 12 and use these resources to build native Mac apps with Mac Catalyst.