Driving Innovation through Advanced R&D Solutions

Qt: An Embedded Developer’s Perspective

Introduction

Welcome to the second part of our blog series exploring the pros and cons of using Qt for embedded systems. In the first part, Bluefruit founder Paul Massey highlighted the business and Agile advantages of Qt. Now, Senior Developer Ben Watts-Jones shares a more cautious perspective, outlining potential pitfalls that teams should consider before adopting Qt.

Acknowledging Bias

It’s important to recognize that Bluefruit specializes in developing software for embedded systems, often utilizing system-level languages like C++ for precise hardware integration and performance. For us, safety, reliability, and robustness are critical. While we don’t typically require complex animations or advanced graphics, we do seek user interfaces that surpass basic bare-metal frameworks. This is where Qt comes into consideration.

That said, opinions on Qt can vary widely depending on the project context.

Key Considerations for Using Qt

1. Don’t Use Qt for Everything

The allure of a single codebase for multiple platforms can be tempting, especially for business stakeholders. However, this approach has its downsides. For instance, using Qt/C++ to compile for WebAssembly may limit the advantages of standard web technologies, while mobile applications built with Qt might miss out on native functionalities.

Moreover, maintaining a unified codebase can complicate documentation and debugging. Each platform may have its own native frameworks, like Apple’s SwiftUI for iOS, which could lead to unnecessary complexity. The costs of managing a non-native codebase can outweigh the benefits, so it’s essential to weigh the trade-offs carefully.

2. Don’t Get Locked In

When deciding on Qt, focus on modularity and clean dependencies rather than viewing it as the sole solution. Qt offers numerous modules that can enhance your application, but they can also increase your dependency on the framework, making it harder to pivot later.

Aim for a thin GUI layer that interfaces with your core business logic through well-defined APIs. This approach allows for easier transitions between frameworks in the future and enables more effective unit testing without tying your business logic to a specific UI implementation. Ultimately, Qt should adapt to your needs, not dictate your architecture.

3. Consider Your Testing Strategy

While Qt provides testing frameworks like Squish, their effectiveness varies. Often, these tools test Qt’s implementation details rather than the actual GUI behavior. If your Qt layer is thin, much of your application logic can be tested independently.

For GUI-specific testing, consider end-to-end strategies. Simulate the application environment, perhaps using OCR to verify text changes after user interactions. However, be aware that this method can be brittle due to potential OCR errors or unexpected UI changes.

Ultimately, no perfect solution exists for GUI testing, but Qt recognizes the importance of testability compared to some other frameworks.

4. Collaborate Early

Qt’s capabilities for responsive and accessible design require thoughtful planning from the start. Retrofitting these features later can be challenging. Unlike web design, which allows for more flexibility with scrolling and scaling, Qt doesn’t adapt as easily.

When planning your project, ensure that designers, developers, and stakeholders collaborate early to address issues like text size and localization. This helps prevent scenarios where initial designs seem functional but lack the flexibility to accommodate diverse user needs.

5. Mileage May Vary

Qt can be a strong option for certain embedded projects, but it should be viewed as just one of many tools available. Prioritize a well-designed, modular architecture with clean dependencies to maintain flexibility and long-term viability. Emphasize your core business logic and embrace collaboration to enhance responsive design and accessibility.

Should You Use Qt for Your Project?

Ultimately, whether to use Qt—or any framework—depends on your specific project requirements. The software development landscape is continually evolving, including licensing models and available functionalities.

When starting a new project with GUI needs, carefully evaluate all options. Consider factors like project scope, resource limitations, and business objectives to make an informed decision. By understanding Qt’s principles and keeping abreast of developments in the field, you’ll be well-positioned to select the right GUI toolkit for your next endeavor.