Jesper K. Pedersen
278 results
QVariant is a cornerstone Qt class used in the property system, model/view, and C++/QML data exchange. It's a type-erased container similar to std::any, storing objects of almost any type while remembering the stored type. This video demonstrates how QVariant works in practice.
"unresolved external symbol 'public: virtual struct QMetaObject ...'" - a mysterious linker error that sometimes occurs when working with QObjects and signals/slots. This video explains what causes it, how to solve it with just one click, and what happens behind the scenes where the build system meets signals and slots.
QObject implements a huge number of features: properties, events, signals and slots, automatic memory management and much more. In this module we are going to explore how they work and how they map to all the QML knowledge that we have built so far.
"When the user clicks this button, run this code" is one of programming's oldest problems. Qt's solution is the signals and slots mechanism: buttons emit signals when clicked, slots contain the code to run, and connections link them together. This video explains creating such connections in C++.
This video continues the signals and slots discussion, exploring three connection methods: pointer to member functions (PMFs), string-based SIGNAL/SLOT macros, and function objects (including lambdas). We'll examine the PMF syntax introduced in Qt 5 and compare it against the string-based approach, discussing the pros and cons of each.
Did you know that you can connect a QObject signal to a lambda function, or to any free function or function object, for what it's worth? It's extremely convenient, but it comes with its own set of "gotchas" that we must understand. In this video we'll explain the syntax and reason behind the good use cases of connecting to a lambda function instead of connecting to a "regular" slot.
In the previous videos of this module we have learned how signals and slots work. We have also learned how to connect an existing signal to an existing slot (in all its variations). In this episode, we will build up on that knowledge and discuss how to declare and implement custom signals and slots – and why we would want to do that!
Sometimes views need more data than what's displayed in a cell. Examples include context menus for employee cells (where only the name shows) or annotation symbols for annotated data. While views could call the model directly, this breaks with proxy models in between.
This video explains how to install and use the SpellChecker plugin for Qt Creator, a third-party contribution. GUI applications contain many user-visible strings, so shipping software with spelling mistakes would be embarrassing. While word processors have long included spell checking, programming editors traditionally lacked this feature - until now!
This video shows how to launch GammaRay right from within Qt Creator, with a convenient keyboard shortcut.
We should use layouts to arrange child widgets in containers. Layouts work automatically, except when they don't! Sometimes we need to fine-tune layout decisions, particularly when they incorrectly handle padding and margins for contents.
When an application is being introspected by GammaRay, you can use Control + Shift + Mouse click on any of its widgets to select it for further inspection. This lets you check all the properties for the widget, its positioning, as well as simply get an answer to the question: of which class is this widget?
We talk about headers in a QTableView. Were you ever slightly annoyed by the fact that you can click on a header and sort the table by the corresponding column, but then you cannot undo the sorting? Let's fix that!
Clang-format is a tool that can automatically reformat your source code. Not only can you run it manually to apply a given formatting, but you can set it up so that it automatically reformats the code when committing into git, or when saving in Qt Creator.
If you find yourself working on a number of projects in Qt Creator and you quickly want to switch between them, just use a different session for each one! Sessions will remember open documents, cursor positions, and much more.
This video visits Qt Designer, this time to discuss combo boxes. Mapping a QComboBox's entry to a specific value is easy in C++, but not so easy when the combo box is populated from within Qt Designer. How do we improve the situation?
In this video, the first of the Qt Widgets series, we show you a few ways to improve your workflow when using a QGridLayout inside Qt Designer. Though it sounds simple, there are a few subtleties involved.
This video shows you how to configure ListView to move by just one element at a time, effectively implementing a form of swiping through pages.
This video discusses ListView's built-in capabilities for animations. When a ListView is populated, or entries are added or removed from the model, etc., ListView can automatically trigger animations on the affected items.
GridView is a strict companion of ListView. As the name says, it's a view – something that shows delegates, instantiated from a model. The delegates are arranged in a reflowing grid, rather than in a vertical or horizontal sequence – a bit like a file manager in icon mode. Apart from this, GridView is extremely similar to ListView.


