Book Review: Cross-Platform Development with Qt 6 and Modern C++

I recently received a review copy of the Cross-Platform Development with Qt 6 and Modern C++ by Nibedit Dey available from Packt. I find it interesting to read books on Qt in the midst of a major version shift, as many of the underpinnings of Qt are revisited and updated by the development teams.

In his book, Nibedit balances between the newer technologies used, e.g. CMake, function reference based signals and slots, etc while referring back to Qt 5 (and even Qt 4) practices such as QMake, the SIGNAL and SLOT macros, and more. This gives a good context to the reader, which is good for the reader, as older practices still are used in older Qt-based codebases.

The book is divided into blocks with increasing depth and complexity. This makes it a good read for the beginner, as well as the more experienced used of Qt. Either you start from the beginning and get introduced to both widgets and QML, or you can dive straight into the more advanced topics such as the model-view concepts.

What I particularly like about the book is the focus on the cross-platform capabilities of Qt. This is how Qt was started, and something that is often lost these days. Qt is more than a UI toolkit and the real strength is the ability to use a single code base to build native applications for the major desktop (and some not so major) as well as the major mobile platforms. This is a reoccuring theme throughout the book where it starts by installing the Qt development environment on all major platforms, discusses how to setup Qt for mobile development, as well as for how to deploy Qt applications in all these scenarios.

There are other highlights too such as the chapter on testing, discussions on profiling and optimizations, and other topics not commonly found in this type of book.

What could be said to be missing is any content on embedded device development, 3D tooling and classes, the design focused tooling, and more. But Qt is such a broad topic these days that it would be impossible to cover it all in a single book.

All in all, this is a recommended read!

XmlListModels in Qt 6

I had a look at a small XmlListModel based project of mine and started migrating the code from Qt 5.12 to Qt 6.2. The code ports pretty cleanly, but there are some caveats to be aware of.

As I’m lazy, I started by changing the imports from 2.12 to 6.2 and tried running the code. The first changes I had to make was to change the import from QtQuick.XmlListModel to QtQml.XmlListModel. I also learned that the import statement no longer requires a specific version to be specified – I’m not sure if I’m a fan of that quite yet.

The second change was that XmlRole has been renamed to XmlListModelRole, and that it no longer has a query property, but an elementName and attributeName property. I guess that saves Qt from having to implement support for XPath queries, and in my use-case (and most others), this should still be enough.

The last change I had to made was to silence a warning. It is no longer encouraged to connect objects directly to signals in QML. In my case, it was animations triggered by the onAdd and onRemove signals in a model. The trick is to declare the animation (in my case, a pair of SequentialAnimation instances, separately. Provide an id for them, and then call start on that id in the signal handler.

All in all, a quite pleasant migration experience with only superficial API changes to handle. All logic could be used as is. Nice!

QmlBook: Felgo Service Integration

Felgo has kindly sponsored the QmlBook, which has resulted in a new chapter. The topic this time around is the Felgo Qt extensions for
integrating various services that are commonly used by app developers, the Felgo cloud builds, as well as their live reloading technology.

When building modern apps there are many things that you might want to integrate – in-app purchases, ads, analytics, user accounts, user settings, real-time sharing of data between devices. Felgo provides integrations of common solutions for this which let’s you focus on developing your app. In the Felgo Plugins chapter, we look at some of them.

Another hassle when developing apps is that you need a Mac to build for Apple devices – unless you use Felgo cloud builds. Felgo cloud builds is a CI/CD solution for building and deploying Qt apps directly to an app store.

In addition to this, the chapter contains a deep dive into the Felgo live reloading solution. We had a quick look at using this in the first Felgo chapter. In this chapter, we look at how you can integrate it into your own executables, as well as how you can use it to develop on multiple devices simultaneously.

Intense weeks

End of October turns out to be one of the highs when it comes to workload this year. Everything happens at once – there are two public events that I’d like to tell you about.

The first one is running lights. This is an annual running competition organized by AIF Friidrott, the sports club my kids are active in. This year, this means organized by me and postponed due to COVID-19, but the virtual races started this weekend and the arena race will take place on the 24th.

If anyone of you are in the Alingsås area and enjoy I highly recommend you to join. The weather looks nice, and we will light up the arena with live fire, so it will be a great evening.

The second one is the foss-north 2020 take II event. This spring, we decided to try to organize a physical foss-north event this fall, as obviously the pandemic must be over by November. This seems to not be the case. :-)

Instead we are running a single day event on November 1 with six handpicked speakers. The event is virtual and free for all.

I would like to tell you about the speakers one by one, because I’m very excited about each and everyone of them.

Andrew 'bunnie' Huang

In the morning we welcome Bunnie Huang who will talk about the precursor project. Precursor is an open hardware platform for secure, mobile communications and computations. The focus is on security aiming to create a trustable platform.

Simon Ser

Next up is Simon Ser. He will talk about how to get pixels onto the screen in a modern Linux stack. This means a deep dive in the Kernel Mode Setting (KMS) interface. How it exposes hardware blocks and how to use it to get images shown on the screen.

Ramón Soto Mathiesen

The morning session then ends with Ramón Soto Mathiesen taking us into the land of Domain Driven Design (DDD) using Algebraic Data Types (ADT). Ramón has a background in functional programming languages and brings this knowledge into the world of multi-paradigm languages such as C#, Rust, and Swift.

Carol Chen

The afternoon session starts with Carol Chen from Red Hat Ansible. She works as a community manager for Ansible. She will be talking about how they move have moved from collections to contributions to conferences.

Lars Brinkhoff

We then continue with Lars Brinkhoff who will talk about the Incompatible Timesharing System (ITS). Lars works with restoring ITS and recreating the history from these early days of computing. ITS is of particular interest at foss-north at is the platform where tools such as Lisp, Logo, Scheme, Emacs and Zork where developed. This is where the foundations for the free software movement where born – quite literally.

Tor-logo by Stanchenko on DeviantArt

The day then ends with Alexander and Georg who will talk about Tor, the anonymity network. They will discuss why diversity is essential for reaching security and anonymity.

So, the next days will be crazy hectic, but it is all for something good. First a cosy evening of running on an arena lit by live fire, and then a day of talks about various FOSS projects.

I hope to see you there!

Felgo in the QML Book

Over the past year I’ve been bumping into the Felgo crew at various Qt events. They take Qt to the next level. It all started as a game development framework for Qt, but has turned into a powerful app development framework taking a lot of the rough corners of Qt, and extending the tooling with a powerful live reloader at the same time.

https://qmlbook.github.io/_images/felgo-logo.png

To showcase how the Felgo SDK fits into the bigger picture, and how much it actually helps creating apps, we agreed to extend the QML Book with a Felgo chapter. The chapter is built around a messaging app and showcases the whole UI creation from initial skeleton to working app.

https://qmlbook.github.io/_images/messaging-stage-2.png

We also cover a bunch of other things such as how to get started, the QML Live reloader, as well as some more advanced topics such as native dialogs, simplified networking and the JsonListModel.

Big thanks goes out to Felgo for supporting this work and helping to make QML Book better.

Akademy 2020

I had the pleasure of speaking at Akademy 2020 this weekend. This year Akademy is virtual, but I still got the feeling of a very interactive event. Interesting questions, greenroom for the speakers, and generally a nice experience. Big thank you to the organizers!

The video below should start roughly when I go on stage.

For the interested listener, you can find the slides here: https://e8johan.se/presentations/2020-09%20akademy%20v1.1.pdf.

It finally arrived

After waiting a bit over a month, followed by an agonizing week when the new gizmo was at my DHL pickup point and I was some 2h by car away in our summer house.

What gizmo? A Pinebook Pro!

The Pinebook comes in many layers. Like, properly many. I guess this means that it is safe during transport. At least mine arrived without any bruising despite a long journey from Hongkong to Alingsås.

After powering the system on it took quite a long time for the system to reach the Manjaro logo, but once up and running, things move along at a decent pace.

Initial impressions are positive. I had to crank up the backlight a bit, but I’m sitting outdoors (it is overcast). Right now I’m installing the initial set of software updates (some 400+MB to download) while I type this. I also set the keyboard layout to Swedish. I have an ISO keyboard model, so all the keys are there and I don’t mind that the keycaps say something else than what they type.

On the topic of the keyboard. I was warned about the keyboard feel. I was also told that the Pro-model is better than the original Pinebook (which I’ve only used for ~5s at fosdem). To be honest, the keyboard is decent, but not on par with my Dell XPS13, nor my Sculpt Egonomic keyboard.

I still have the night time hacking test to perform – will my wife accept this keyboard clicking in the early morning hours? She preferred the MacBook Pro over the XPS13, so let’s see how this fares ;-).

I also have to see if I can adopt to Manjaro Linux, or if I’ll go to Debian, which I run on all my other machines. It has been years since I tried any alternative distro, so I’ll give it a few days at least to see how much I will miss apt-get – at least it runs KDE Plasma ;-)

foss-north kdenlive workflow

As some of you might already have noticed, we’ve complemented foss-north with a new pod / vod / vlog – I’m not sure what to call it. Basically, it is a video based pod cast (making it available as a audio only pod-cast is high on the todo). Our main focus right now is a series on licenses and copyright, but there is more to come.

As a part of this, I’ve started editing videos in kdenlive on a weekly basis, and I’m very happy with it so far.

In this blog, I want to share my workflow. It is probably far from ideal, but it does the work for me.

I usually start with a set of presentation slides that we’ve used to direct the discussions. These are exported as pdf, which is then converted to 1920×1080 pngs for consumtion in kdenlive.

I do this in two steps using ImageMagick, as the results seems nicer by first rendering too large images and scaling them down.

convert -verbose -density 300 ../open\ projects-1.pdf -quality 100 -sharpen 0x1.0 11.png

mogrify -resize 1920x1080 *.png

The session is recorded using OBS from our Jitsi instance, but we also encourage each participant to record their audio separately, as it makes it easier to fix things afterwards. (foss-north now self-hosts a Jitsi instance – check out https://github.com/e8johan/virtual-conf-resources to learn about how to setup virtual conferences).

You would be surprised over how many times we’ve run into issues with one or more sound recordings. We’ve had:

  • Too low volume (inaudible)
  • Too high gain (noisy)
  • Local echo of the rest of the participants in one recording (no use of headphones)
  • No recording (forgot to press record)

I’m sure the list will grow longer as we record more episodes :-)

Before I start cutting the recording, I use one of my favorite features in kdenlive. First I set the Jitsi recording as the audio reference as shown below.

Then for each audio track, I tell kdenlive to align it to the reference. This will position it correctly in relation to the Jitsi recording, meaning that I can fade in and out of individual recordings without having to worry about any time shifts.

Finally, I select all the audio recordings and group them. This means that all editing I do (cuts, movements, etc) is applied to all channels.

Now it is just a matter of listening for trouble (you can spot awkward silence in the visualization of the audio tracks), press i to mark the beginning of a section, press o to mark the end, and then shift+X to cut it out.

In general, I try to edit as little as possible, but tightening some parts by removing silence, and sometimes remove failed parts when we’ve decided to start over a section.

Finally I add the pngs as a video stream, our pre-recorded intro sequence, and a YouTube friendly end-screen and click render and go to bed :-)

What a License Track!

The foss-north 2020 videos are rolling out. This year we’re doing a small experiment, so everything is available at once over at conf.tube, while we roll the videos out gradually at YouTube in an attempt to feed the algorithm (like and subscribe!).

This year we had a great set of licensing related talks, and I’d like to discuss them all in this post.

Monday morning started with Frank Karlitschek and his talk Why the GPL is great for business. This a great overview of how you can build an free and open source business – pros and cons and pitfalls to avoid.

Next up is Gabriel Ku Wei Bin from FSFE who talked about REUSE. The REUSE project is about helping creators choose and apply free and open source licenses.

This is followed by Pavel Kopylov and his talk Hacking the legal code of an open source license. This talk is about understanding how licenses works and how to use them.

This is followed by Jason Hammond from Whitesource talking about their compliance tooling and why compliance is important.

The final talk in this track is by Adriaan de Groot talking about the KDE Free Qt Foundation. This is an interesting aspect, as it is about protecting the customers by offering a more liberal license at a given point of time.

Historically we’ve always split talks on a specific topic during the conference to ensure that people move about in the hallways and that most visitors get to see something unexpected. Since we record everything, we can now do both – clustering by topic and a linear playlist.