Jump to content

Qt for HarmonyOS development with 6.12.0

From Qt Wiki
Revision as of 05:11, 19 October 2026 by Shawn Luo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Qt 6.12.0 now officially provides prebuilt HarmonyOS packages via the Qt Online Installer!

Through the Qt Online Installer, you can check the "HarmonyOS" entry under "Qt 6.12.0" to install the prebuilt Qt libraries for the HarmonyOS target platform.

Installing via Qt Online Installer

Qt Online Installer download address:

https://www.qt.io/development/download-qt-installer-oss

Download the version corresponding to your operating system. The following takes installing the Qt 6.12.0 HarmonyOS components as an example.

1. Launch the installed "Qt Online Installer" and click Next.

Qt Online Installer welcome screen

2. Enter the login screen, sign in to your Qt account, and click Next.

Sign in to Qt account

3. Check the corresponding terms. Enterprise users must fill in their company name, while individual users should check "I am an individual user", then click Next.

Accept terms

4. If you want to customize the installation directory, click Browse in the upper right corner to select the directory where you want to install Qt. Then check "Custom installation" below and uncheck all other options, and click Next.

Select installation directory and custom installation

5. Sequentially expand "Qt for Development" -> "Qt" -> "Qt 6.12.0", and check "HarmonyOS". Other optional items can be checked as needed, where Sources contains the complete source code of the Qt framework. Once selected, click Next.

Check HarmonyOS component under Qt 6.12.0

6. Read and accept the license agreement, then click Next.

License agreement

7. You can keep the defaults and click Next.

Start menu shortcut settings

8. Click Install and wait for the installation to complete.

Installation in progress

9. Once the installation is complete, click Finish.

Installation complete

After installation (taking Windows installed to C:\Qt as an example):

  • Host (Windows) build is located at: C:\Qt\6.12.0\mingw_64
  • HarmonyOS target build is located at: C:\Qt\6.12.0\harmonyos_arm64_v8a

macOS(Apple Silicon)

For examples, you have everything installed at ~/Qt. Your host build will be at ~/Qt/6.12.0/macos . You can install "HarmonyOS" item under "Qt 6.12.0", then you will get it at ~/Qt/6.12.0/harmonyos_arm64_v8a .

For DevEco Studio and SDK, you need to install DevEco Studio 6.1.0 Release(DevEco Studio for Mac(ARM) 6.1.0.860(3.4GB)) via https://developer.huawei.com/consumer/cn/deveco-studio/ . Then you will have SDK with API 23 at /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony .

For Qt 6.12.0 Beta

Get Additional Packages via https://wiki.qt.io/Building_Qt6_for_HarmonyOS#Additional_Packages , you can put them at .local/opt/ohos/additional-packages .

(Note: this is not needed from Qt 6.12.0, which starts to use static libs for 3rdparty dependencies, see also https://codereview.qt-project.org/q/topic:%22harmonyos_static_additional_package%22 )

Set OHOS_SDK_ROOT

$ export OHOS_SDK_ROOT=/Applications/DevEco-Studio.app/Contents/sdk/default/openharmony

Trying to build an example

$ cd ~/Qt/Examples/Qt-6.12.0/widgets/gallery
$ mkdir build
$ cd build
$ ~/Qt/6.12.0/harmonyos_arm64_v8a/bin/qt-cmake ..
$ cmake --build . --parallel
$ ~/Qt/6.12.0/macos/bin/harmonydeployqt --verbose --hvigor /Applications/DevEco-Studio.app/Contents/tools/hvigor/bin/hvigorw --input ./gallery-harmony-deployment-settings.json

Then you can use DevEco Studio to open the project under ~/Qt/Examples/Qt-6.12.0/widgets/gallery/build/libgallery-harmonyos , sign the package, build it and deploy it to device.

Windows

For examples, you have everything installed atC:\Qt. Your host build will be atC:\Qt\6.12.0\mingw_64. You can install "HarmonyOS" item under "Qt 6.12.0", then you will get it atC:\Qt\6.12.0\harmonyos_arm64_v8a. For DevEco Studio and SDK, you need to install DevEco Studio 6.1.0 Release (DevEco Studio for Windows 6.1.0) via https://developer.huawei.com/consumer/cn/deveco-studio/ , and install it toC:\Huawei\DevEcoStudio.

Note on the DevEco Studio path: DevEco Studio installs by default under C:\Program Files\Huawei\DevEco Studio. Spaces in that path can cause failures during the cross-compile build/bundling steps, which is why installing it to a space-free path such as C:\Huawei\DevEcoStudio is recommended.

The commands below assume that location. For the SDK, DevEco Studio ships with a bundled one atC:\Huawei\DevEcoStudio\sdk\default\openharmony. If you instead download multiple SDK versions through DevEco Studio's SDK Manager, they land under%USERPROFILE%\AppData\Local\OpenHarmony\Sdk, so API 23 will be at%USERPROFILE%\AppData\Local\OpenHarmony\Sdk\23and its native toolchain at%USERPROFILE%\AppData\Local\OpenHarmony\Sdk\23\native. This guide uses the latter (API 23).

Note on install locations: the paths above are what this guide assumes; they will differ per machine, so adjust them to match your own setup.

Trying to build an example

Run the following from a Windows command prompt (cmd). Adjust the paths to match your own SDK and Qt locations.

cd C:\Qt\Examples\Qt-6.12.0\widgets\gallery

SET HARMONY_OS_API_VER=23
SET OHOS_SDK_ROOT=%USERPROFILE%/AppData/Local/OpenHarmony/Sdk
SET OHOS_SDK=%OHOS_SDK_ROOT%/%HARMONY_OS_API_VER%
SET NATIVE_OHOS_SDK=%OHOS_SDK%/native
SET ARCH="arm64-v8a"
SET PATH=%NATIVE_OHOS_SDK%\build-tools\cmake\bin;%PATH%

C:\Qt\6.12.0\harmonyos_arm64_v8a\bin\qt-cmake.bat -B build -S . -G Ninja ^
  -DCMAKE_TOOLCHAIN_FILE="C:/Qt/6.12.0/harmonyos_arm64_v8a/lib/cmake/Qt6/qt.toolchain.cmake" ^
  -DQT_HOST_PATH="C:/Qt/6.12.0/mingw_64" ^
  -DQT_CHAINLOAD_TOOLCHAIN_FILE="%NATIVE_OHOS_SDK%/build/cmake/ohos.toolchain.cmake" ^
  -DOHOS_ARCH=%ARCH% ^
  -DOHOS_SDK_NATIVE="%NATIVE_OHOS_SDK%" ^

cmake --build build --parallel

Bundling and deployment

After the build succeeds, runharmonydeployqt6to generate the DevEco Studio project. Set the environment variables so the bundling step finds Node.js, the JDK, and the DevEco SDK. Node.js and the JDK (jbr) are bundled with DevEco Studio.

SET NODE_HOME=C:/Huawei/DevEcoStudio/tools/node
SET JAVA_HOME=C:/Huawei/DevEcoStudio/jbr/bin
SET DEVECO_SDK_HOME=C:/Huawei/DevEcoStudio
SET PATH=%PATH%;%NODE_HOME%;%JAVA_HOME%

C:\Qt\6.12.0\mingw_64\bin\harmonydeployqt6.exe ^
  --input gallery-harmony-deployment-settings.json ^
  --output .\tmp ^
  --verbose ^
  --hvigor C:\Huawei\DevEcoStudio\tools\hvigor\bin\hvigorw.bat

Then you can use DevEco Studio to open the generated project under the output directory.\tmp, then sign the package, build it and deploy it to device.

Reference

Happy Hacking!