The Journey to Qt 6: Felgo’s Learnings and Why it's Time to Migrate

This is a guest blog post by FELGO, an official Qt Technology and Service Partner.

Felgo has actively participated in the Qt ecosystem for many years and builds specialized products that support Qt developers in their daily work. This includes the Felgo SDK with 200+ components that simplify cross-platform development and tools such as QML Hot Reload and Felgo Cloud Builds. Ever since the first release of Felgo based on Qt 4, the team has kept a close eye on every new Qt version to adopt the latest changes and bring all new advancements to the Felgo products and Felgo users alike.

Felgo-qt6

Due to the nature of Felgo and its products, the team is well-versed in evaluating and incorporating new Qt releases. However, major version updates, like going from Qt 4 to Qt 5 and now to Qt 6, always come with significant changes that require special attention. In addition, Felgo has to ensure that the migration is not only smooth for their own products but also for customers all around the world who rely on the Felgo SDK for building their software.

As soon as Qt 6 was released, Felgo started to assess the feasibility and benefits of migration. The team weighed factors such as performance enhancements, developer experience, and the compatibility of existing codebases. This post summarizes the main steps to start using Qt 6 for your products, some challenges Felgo faced during migration, and the benefits of leveraging the new technology.

Why it's Time to Migrate

While the migration requires some planning and development effort, the advantages of Qt 6 far outmatch the inconveniences during migration. After incorporating Qt 6, Felgo now benefits from many advancements, such as improved performance, enhanced developer tools, and future-proof cross-platform compatibility:

  • Qt 6 introduces various optimizations and enhancements that allow applications to run faster and more stable. The revamped rendering architecture and better optimization improve overall application performance, faster startup times, and smoother user interactions.

  • CMake, as the new default build system, is fast, powerful, and comes with various commands and settings for all kinds of use cases, making advanced build scenarios easier to solve.

  • Qt 6's cross-platform compatibility ensures that Felgo's applications can seamlessly run on all the latest operating systems and devices, including Mobile, Desktop, Embedded, and WebAssembly.

Qt 6 made the right design choices, and with the improved performance, stability, and architecture, it is more powerful than ever. By migrating to Qt 6, developers can position themselves at the forefront of technology, seize new opportunities, and deliver exceptional applications that meet the evolving needs of their users.

Steps for a Successful Migration to Qt  6

Before migrating a software product to Qt 6, the most important step is thoroughly evaluating the existing code base and the used Qt components and modules. This enables you to identify parts that require refactoring and draft a roadmap for the migration.

The migration to Qt 6 involves several changes to ensure a smooth transition while preserving the integrity of existing projects. The following topics must be addressed to align with the Qt 6 framework:

Project Configuration, Toolchain and IDE Support

CMake is now the preferred build system, as it has many advantages over qmake. CMake speeds up project compilation and simplifies managing QML modules and project resources (QRC). It also enables Qt to significantly increase application performance, e.g., with the improved optimization capabilities of the Qt Quick Compiler.

CMake and Qt’s CMake helpers also make it easier to support Qt 5 and Qt 6 in parallel with the same project source code, e.g., with the version-less targets.

In addition, the necessary build tools, IDE, and build automation systems need to be updated to match the latest requirements to support building Qt 6 and CMake projects for your target platforms. It is best to tackle these issues early on so you can rely on your CI/CD systems to ensure a solid development process, incorporate quality assurance measures, and benefit from fast deployment cycles during the migration.

Changes to C++ and QML APIs

The APIs of various Qt components changed. Thus, you must incorporate these changes to build and run your project with Qt 6 successfully. Applying the necessary changes is straightforward for most use cases. See the Changes to Qt Modules in Qt 6 documentation page for more information. Some examples are:

  • Bearer management is removed from Qt Network, and the QNetworkConfiguration and QNetworkConfigurationManager classes no longer exist.

  • The QRegExp type is now named QRegularExpression.

  • Qt Multimedia is removing the QML Audio type. You now play audio files with a MediaPlayer and AudioOutput instead.

  • The QtGraphicalEffects module is not part of Qt 6. Some of the effects are available with the Qt5Compat.GraphicalEffects module. The change in the import statement adds additional complexity if you still need to support Qt 5 and Qt 6 in your code. To work around this, you can either use CMake’s configure_file function or use Qt file selectors to include different QML files per Qt version.

  • The Qt Quick Controls 1 module is no longer available, and you have to use Qt Quick Controls 2 or an alternative UI library such as the Felgo SDK instead.

Addressing Functional Differences

Due to changes in the underlying architecture of Qt 6, various features behave differently, which requires changes in your project source code. Here are some examples:


  • Qt 6 introduces a new rendering hardware abstraction layer, which affects features that rely on native rendering. In Felgo’s case, some features require the use of OpenGL, which can be solved by configuring the graphics API that Qt should use, e.g., with setting: QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);

  • High-dpi mode for rendering density-independent user interfaces is enabled by default now. The Qt::AA_EnableHighDpiScaling setting is no longer required, and it is not advised to disable it unless for testing purposes.

  • The window menu bar of Qt Quick applications is now a custom-rendered menu. This means that the menu style is consistent across platforms and does not automatically adapt to native menu solutions of the respective platform. When using C++ widgets, there’s no change, and the platform-native menu is used.

Syntax Changes to Qt Quick and QML

Qt Quick code no longer requires a specific version for module imports. Also, signal handlers without defined parameters are deprecated and should be replaced. This example uses a version-less import and shows how to access the mouse event object of the MouseArea::clicked signal:

import QtQuick


MouseArea {

  acceptedButtons: Qt.LeftButton | Qt.RightButton

  onClicked: (mouse) => {

               if (mouse.button === Qt.LeftButton) {

                 console.log("left clicked");
               }

               else {

                 console.log("right clicked");

             }

      }

}

 


If you still need to support Qt 5 and Qt 6 in parallel, you can keep your “2.x” import versions in code.

The Felgo Approach to Qt  6 Migration

The Felgo SDK takes advantage of many different Qt modules and features. It was not feasible to immediately switch to Qt 6 as the primary target version when 6.0 was released.

Instead, Felgo decided to take a step-by-step approach to the migration, first creating a base version with a minimum feature set of the Felgo SDK. With each new Qt release, Felgo iterated the version until the SDK supported all of the core functionality and modules, which was the Qt 6.2 release at the end of 2021.

Felgo-qtversions

To add all the remaining Felgo features, the team then continued this process until the Qt 6.4.1 release, which was the final building block for the first Felgo 4 release.

In addition, it was clear that tools such as Felgo QML Hot Reload and Felgo Cloud Builds are helpful during the migration process. Thus, the team first focused on preparing these tools for Qt 6. This decision made future work on the Felgo SDK components and collaboration within the team much more straightforward and allowed us to move fast.

felgo-overview

Soon after the Felgo tools and the core feature set were fully migrated, Felgo started to meticulously test every byte of the solution internally and with selected customers.

Leveraging Felgo Tools: QML Hot Reload 

The Felgo SDK and tools have a strong focus on Qt Quick, and QML Hot Reload proved to be an invaluable asset for Felgo during the migration to Qt 6. It allows developers to make real-time changes to the QML code and see the updates instantly reflected in the running application without losing the current state. This eliminates the need for time-consuming recompilation and restarts. 

 



The boost in productivity allowed Felgo to iterate rapidly on their QML APIs and experiment with different design choices. This made refactoring and migrating Felgo SDK controls and UI components much more straightforward.

It also facilitated ongoing improvements and fine-tuning as the team embraced the capabilities of Qt 6. The latest version of QML Hot Reload for Qt 6 additionally gained new features such as an error screen and the ability to roll back changes and errors for a seamless reload experience.

Streamlined Development with Felgo Cloud Builds CI/CD

In addition to QML Hot Reload, Felgo also harnessed the power of Cloud Builds as a convenient and efficient solution for building and deploying Qt 6 applications.

 

With Cloud Builds, Felgo developers can leverage a scalable cloud infrastructure to compile Qt projects. This accelerated the migration process and enabled the integration of Qt 6 into many different customer projects.

Felgo-cloudbuilds2

With the ability to build multiple platforms simultaneously, Felgo Cloud Builds allowed the team to ensure fast development cycles and deliver and test efficiently.

Felgo: Your Qt 6 Migration Partner

300x150_felgo logo

As we have discussed, Qt 6 is a big step forward in quality and ease of use, and most projects will benefit from migrating from earlier Qt versions. Felgo, with its combination of tools and Qt experts, is ideally suited for helping you enjoy the benefits of Qt 6 without delay.

Felgo's powerful tools, such as QML Hot Reload and Cloud Builds, streamlined development and accelerated the adoption of Qt 6. The migration also lays the foundation for future projects, ensuring high-quality applications and efficient utilization of Qt 6's capabilities.

Felgo is ready to help you migrate to Qt 6 with training, consulting, tools, and experts. Whether you are looking for migration knowledge or want to hand off your migration to free up your development time, Felgo is ready to help you with your Qt 6 journey!

If you are attending the upcoming Qt World Summit 2023 in Berlin, don’t forget to stop by the Felgo booth to learn more about their unique products for efficient development. The Felgo team welcomes you with many exciting demos and insights.

------

About Felgo

Felgo has been a Qt Technology Partner since 2014, with the goal of helping Qt developers be more productive.

Felgo is also a Qt Service Partner for development services, Qt training, and workshops. To learn more about Felgo, visit their website or booth at the Qt World Summit 2023 in Berlin on November 28-29, 2023.

 


Blog Topics:

Comments