KDAB_Tree_Header_Mobile KDAB_Tree_Header_Web

Trusted Software Excellence since 1999

Jesper K. Pedersen

269 results

You have likely heard it before - "no raw for loops, use algorithms instead". In this episode, Jesper will give a few examples of code that became much cleaner when rewritten from raw loops to algorithms. Further, he will introduce an algorithm library he has written to make it much less painful to write code using algorithms.

When making large code changes, you want to validate there are no side effects. While unit testing is ideal and Squish tests are good, both may be unrealistic. A "better than nothing" solution is running original and modified applications side-by-side and comparing them. This small application easily takes screenshots of each and compares them.

This series often steps into Qt source code to diagnose problems, which is invaluable for understanding issues behind the scenes. However, the source code contains obstacles like Q_D macros and mysterious d and q variables that aren't immediately clear.

For a while, I thought Qt Creator's rename symbols and grep had a bug when they didn't find all occurrences. After filing a bug report, I learned it's actually a feature - you need to add all header files to CMakeLists.txt for it to work properly. This video shows how to fix your CMakeLists.txt files.

Following a previous clang-tidy episode, this video covers fine-tuning which checks to enable, including some bad surprises encountered. The result is an improved .clang-tidy file with additional checks, plus a script to generate the file and avoid common problems.

CMake's AUTOMOC runs moc automatically but compiles all moc files together, causing extensive recompilation when touching any Q_OBJECT header. Including moc files in .cpp files reduced recompile time from 22 seconds to 5 seconds. This episode includes a script to automate this plus a git hook to ensure you always include moc files.

You can speed up Qt applications almost for free by adding a single define to enable QStringBuilder. The catch: your code may fail to compile or crash in some places, but clazy will warn about potential crashes and the compiler will catch errors.

Qt comes with lots of classes relating to strings these days, including QString, QStringView, QStringLiteral etc. It comes with so many that I lost track, so maybe it is time to call my good friend Peppe. In this episode we will discuss what you need to know to get it right at least 95% of the cases, without knowing it all.

In the previous two episodes we looked at Qt's support for rendering items in the model/view framework. In this episode we will turn our attention to custom delegates for editing items. In the KDAB gift shop we will receive a ready to use delegate for choosing items with a combo box.

In the previous episode, Jesper presented a new delegate super class, namely QWAMDelegate. In this episode, he demonstrates three use cases for delegates showing a “progress bar”, HTML, and an amount, an arrow and a percentage change.

QListView, QTableView and QTreeView can all be configured via a number of roles from the models, e.g. BackgroundRole, ForegroundRole, FontRole, and TextAlignmentRole. This often means that no additional configurations of the views are needed.

This episode completes the inline headers implementation by adding the required signal connections. It expands into class design discussion, showing how to create drop-in replacements for QTableView and QTreeView with row span support while avoiding code duplication through templated superclasses and private class inheritance.

This episode discusses runtime QVariant issues encountered during Qt 6 migration of an in-house tool. Topics include debugging QVariant problems, using QVariant::fromValue for solutions, issues with QVariant::toString(), the removal of QVariant operator<(), using QVariant::compare, and improved Money comparison in both Qt 5 and Qt 6.

This episode shows a specialized combo box for solving this simple problem:

Efficient software developers avoid repetitive tasks by using tools like Perl, Python, or Bash on source code outside their IDE. Qt Creator offers macro recording facilities that, combined with block commands, can handle many such tasks.

This episode explores C++'s explicit keyword: why there's no implicit keyword, why it's needed for QObjects, and available tooling. Topics include implicit conversions in string classes, when conversions go wrong, explicit to the rescue, named constructors, QObject-specific issues, Q_IMPLICIT, explicit(false), clang-tidy support, and rules for when implicit conversions are acceptable.

This episode completes the proxy model for reversing rows by handling the challenging layoutAboutToBeChanged signal. It covers understanding QModelIndex, updating persistent model indexes, layoutAboutToBeChanged and layoutChanged signals, and why persistent index updates differ for other operations like rowsInserted.

One of the most complex things in Qt's model/view framework is the implementation of proxy models.This episode shows an almost complete implementation of a proxy model which reverses its rows but, at the same time, also gives hints for where and when you can cut corners.

JesperKjaerPedersen

Jesper K. Pedersen

HR Director / COO