KDAB_Tree_Header_Mobile KDAB_Tree_Header_Web

Trusted Software Excellence since 1999

Jesper K. Pedersen

278 results

In this episode, Jesper interviews Peppe on a helper class called propogate_const, which also makes the pointed-to object const in const methods.

Generally, you need Qt 6.4 to use Qt's Structural Bindings feature, which iterates the values of a Map or QHash elegantly. This episode shows how you to enable it for older Qt versions too.

In this episode I'll show how to work with git sub-modules, and especially how to cope with changes coming in from sub-modules. I'll also discuss the issues of switching branches or doing a git bisect when your project contains sub-modules.

When using external git projects in your codebase, copying code is simplest but makes updates difficult. A better alternative is git submodules. This episode demonstrates creating submodules using the kdalgorithms GitHub module and shares tricks for easier submodule management in CMake projects.

This episode builds on the previous three to understand complex template code - a modified transform function that takes containers instead of iterators and returns transformed containers. The key feature is smart container reuse: when result and input containers are the same type and input is an r-value, it reuses the input container rather than creating new ones.

Template code commonly uses type traits to test type properties: is it an l-value, is it const, does it have a method, etc. This episode investigates how type traits are implemented by creating our own versions of is_same_v, is_const_v, and integral_constant, building foundational knowledge for understanding complex template code like type comparisons and r-value detection.

This video shows how to "overload" templates with two real-world examples: a sort function with general implementation plus char specialization, and a vector implementation with boolean specialization for space efficiency. Finally, we'll see how to make C++ reveal what type a template parameter represents.

In this episode we will start slowly understanding what a template is, but within 15 minutes we will have seen the assembly code generated, have discussed template type parameters and non-type parameters, and finally have discussed template template parameters (no that is not a mistake that it says template twice!)

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.

JesperKjaerPedersen

Jesper K. Pedersen

HR Director / COO