WinRT
Microsoft introduced a new design paradigm with the Windows 8 Modern UI. A core part of this new approach is Windows Runtime (WinRT) that supports development using different programming languages, such as C++/CX (component extensions), C# VB.NET, or JavaScript. The Qt port uses the C++ capabilities. While WinRT supports the component extensions internally, they are not used inside Qt and you do not need to use them. WinRT applications run in a sandboxed environment for security reasons and support different architectures, such as ARM and x86.
Qt's WinRT port supports the following:
- Widgets
- Graphics view
- Touch and orientation events
Getting Started
Qt for WinRT is always built as a cross-build, because tools, such as qmake, are built as desktop applications. It also does not really make a difference whether you target a desktop computer or a phone, except that you have to configure Qt using the correct xplatform. The WinRT mkspec format is <platform>-<architecture>-<toolchain> where platform can be winrt or winphone and architecture can be arm, x86, or x64. The following is an example of building qtbase for WinRT:
> ./configure -xplatform winrt-x64-msvc2012 -developer-build -release > nmake/jom
To use the latest sources, check out the dev branch before building.
Building Applications
You can develop applications for WinRT just as any other Qt applications. Use your favorite editor or IDE (such as Qt Creator) and create your application or load a Qt example. Then run qmake and nmake/jom to build your application.
Running Applications
Unfortunately, running WinRT applications is not as easy, yet. Applications can only be started as part of an application package or by registering them internally. The easiest way of registering your application is to copy its content to a dedicated directory. The package content consists of the application executable and its dependencies, as for every other non-WinRT Windows application. The dependencies are the needed (Qt) libraries and plugins. Note that Qt plugins have to be put into a folder named after their category (platforms, imageformats, and so on) without using a plugins folder as root. For more information, see Deploying an Application on Windows.
As WinRT applications are run in a sandboxed environment, setting the path variable to point to the files required will not work.
The deployqt convenience tool looks up the application's dependencies and copies Qt libraries and plugins to the appropriate directories, as necessary.
In order to be able to run debug builds of your applications you have to register the correct VCLib debug framework. This framework provides the C++ Runtime for Modern UI applications and its files can usually be found in <Path to Microsoft SDKs><Windows version>\ExtensionSDKs
\Microsoft
.VCLibs<VC Version>\AppX
\Debug
<CPU architecture> To register the debug VCLibs for x64 for Visual Studio 2013 on Windows 8.1, run the following command in PowerShell:
> Add-AppxPackage 'C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1\ExtensionSDKs\Microsoft.VCLibs\12.0\AppX\Debug\x64\Microsoft.VCLibs.x64.Debug.12.00.appx'
Because all resources are placed to one directory, you can register the directory using an XML file (AppxManifest.xml) and Windows Powershell. The reference for these manifest files can be found here. If you are using a debug build, your AppxManifest has to provide information about its dependency on the just added VCLibs. Additionally, the target processor architecture must be specified (as opposed to the default, 'neutral'). As soon as these requirements are met, change into your packaged directory in PowerShell and call:
> Add-AppxPackage -Register AppxManifest.xml
If that worked, you should be able to find your application in Windows 8's start screen. To remove your application, use Windows' built-in way to uninstall applications (right-click or tap and hold the application and choose Uninstall).