Sign up for the KDAB Newsletter
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Find what you need - explore our website and developer resources
25 September 2025
AI-driven software development tools are rapidly evolving, promising to ease the pain points of code maintenance, feature extension, and large-scale refactoring. In this second part of our blog series about coding with AI we explore one of the most prominent recent advances in this space is GitHub Copilot’s new “Agent mode,” which brings a more holistic approach to code suggestions and modifications - especially valuable for projects spanning multiple files and languages, such as C++ backends for QML user interfaces. (Read the first part here)
The test case for this exploration (also see video below) is a small QML/C++ application displaying a list of countries with their names, flags, and population numbers. The challenge: extend the application to also show the area (in square kilometers) for each country.
This isn’t a trivial change; it requires updates to the data structures, model logic, and user interface across both C++ and QML. Developers used to Qt models and how they interface with QML might remember the steep learning curve associated with the pattern.
In order to successfully complete the task the following changes to the code are necessary. The data structure on the C++ side changes like this:
struct Data {
QString name;
QString flag;
double population;
+ double size;
}
The model interface in the C++ header file is modified like this:
enum Roles {
NameRole = Qt::UserRole,
FlagRole,
PopulationRole,
+ SizeRole,
};
The model logic in C++ is also adjusted, in multiple locations. First change the data function,
QVariant MyModel::data(const QModelIndex &index, int role) const
{
// [...]
switch (role) {
// [...]
+ case SizeRole:
+ return data.size;
// [....]
}
}
and then the role enum to name mapping:
QHash<int, QByteArray> MyModel::roleNames() const
{
static QHash<int, QByteArray> mapping {
{NameRole, "name"}, {FlagRole, "flag"},
{PopulationRole, "population"},
+ {SizeRole, "size"},
}
return mapping;
}
Finally, the QML code needs to display the newly available data:
Text {
- text: model.name + "\n" + "population: " + model.population.toFixed(3) + "mill.\n"
+ text: model.name + "\n" + "population: " + model.population.toFixed(3) + "mill.\n" + "size: " + model.size.toFixed(2) + " km2"
}
As you can see, the code change affects multiple layers of code and requires prior understanding about how the C++ layer and the QML layer interact.
As you can see in the linked video, GitHub Copilot successfully completes this task, making appropriate edits to all relevant files. To achieve this, Copilot’s Agent mode analyzes the entire repository. Simpler LLM chat tools only see the context the user passes on, by copy paste or adding files to the chat context. This means the LLM might miss important clues to complete the task.
When asked to add a new “area” attribute, Copilot in Agent mode
In doing this, Agent mode helps QML developers to execute a typical but tedious multi-file, multi-language edit without losing control over the actual changes to the code.
Despite Copilot’s impressive automation, review by a human developer is still essential. The tool’s suggestions may include unwanted formatting changes, introduce unrelated modifications and introduce unexpected issues into the code base. The process benefits significantly from the developer’s ability to accept, reject, or further refine each change. Moreover, when prompted to improve the data model by introducing a dedicated type for population size - making units explicit, rather than relying on ambiguous raw numbers - Copilot’s output, while helpful, did not fully capture the developer’s intention. The semantic clarity required (such as distinguishing millions from billions) was missing. This underscores the importance of domain expertise and critical oversight: AI can accelerate refactoring, but cannot (yet) replace the nuanced understanding of experienced developers.
AI tooling is rapidly maturing, and integrating these tools into daily development workflows can yield significant productivity gains. However, developers should continue to apply their own judgment and maintain control over the codebase - a partnership between human expertise and machine assistance is where the real power lies.
About KDAB
The KDAB Group is a globally recognized provider for software consulting, development and training, specializing in embedded devices and complex cross-platform desktop applications. In addition to being leading experts in Qt, C++ and 3D technologies for over two decades, KDAB provides deep expertise across the stack, including Linux, Rust and modern UI frameworks. With 100+ employees from 20 countries and offices in Sweden, Germany, USA, France and UK, we serve clients around the world.
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Learn Modern C++
Our hands-on Modern C++ training courses are designed to quickly familiarize newcomers with the language. They also update professional C++ developers on the latest changes in the language and standard library introduced in recent C++ editions.
Learn more