Programming

Latest posts — page 3

Pretty-Printing Output for QCOMPARE

We have created a custom class, say Person, and use it in a unit test. void TestPerson::testEquality() { Person p1("Alice", 42); Person p2("Bob", 37); QCOMPARE(p1, p2); } The unit test fails with this message.

Passing Enum Properties between C++ and QML

We have defined a Qt property warningLevel in the C++ class MainModel: Q_PROPERTY(WarningLevel::Enum warningLevel READ warningLevel WRITE setWarningLevel NOTIFY warningLevelChanged) We want to use this property in QML. For example, we want to colour a rectangle according

Responsive QML HMIs with File Selectors

In my previous post, I have shown how to use scaling to adapt QML HMIs to different screen sizes and formats. We reach the limits of scaling if we must change the structure of the HMI or if the HMI

Responsive QML HMIs with Scaling

The HMIs of in-vehicle infotainment systems, TVs, phones and many other systems must adapt to different screen resolutions and formats. This adaptation should happen with as little duplicate effort as possible. The simplest way of doing this for QML HMIs

Casting a negative float to an unsigned int

Never cast a negative float to an unsigned int. The result of the cast differs depending on whether the cast is executed on a device with Intel or ARM architecture. The C++ Standard decrees that the result of such a