Updating my RSSReader from Qt5 to Qt6
published at 10.07.2025 15:59 by Jens Weller
Save to Instapaper Pocket
Never touch a running system is maybe something that you're familiar with. But one day that system stops running, and you decide to get on with the long overdue updates. So this week I've ported my RSSReader for Meeting C++ from Qt5 to Qt6.9.1.
I've blogged about my experience 3 years ago when I ported the conference tooling to Qt6. Some of the same issues did come up again, like QStringRef. As this application does not go into painting or PDFs at all, some of the other issues didn't show up. In general this was an easy port without too many issues. The biggest one is runtime related, only showing up once you run the program.
QRegExp and QStringRef
Lets start with two obsolete classes, which you should replace with their new Type or if you can with auto. Using auto would have prevented some of the issues with QStringRef, as it is not hard coding the type in code where you declare a variable for a return value from a function or method. QRegExp should be replaced with QRegularExpression, while QStringRef now is QStringView.
QDateTime::fromString
RSS has a well defined date field of the type RFC822, which is ancient. I've ported a parser for this to boost::spirit a long time ago. But its not the case that everyone is compliant with this part of the RSS Standard. So I do have a function trying to parse a date string with every format there is until it succeeds or fails with every attempt. This uses QDateTime::fromString(QString,Qt::DateFormat). And with Qt6 the enum for DateFormats changed, removing some of the prior members:
if(!date.isValid()) date = QDateTime::fromString(strdate,Qt::SystemLocaleDate); if(!date.isValid()) date = QDateTime::fromString(strdate,Qt::SystemLocaleLongDate); if(!date.isValid()) date = QDateTime::fromString(strdate,Qt::DefaultLocaleLongDate); if(!date.isValid()) date = QDateTime::fromString(strdate,Qt::DefaultLocaleShortDate);
These 4 are now not supported anymore in Qt::DateFormat. I wonder if there is a way to loop over the values of an enum instead of hard coding this like here. I'm not sure when RFC2822Date was added to this enum, but I've added this now also to this code. Even if I already run a parser for this. One of the recent issues was that someone had a RFC822 date with 25 instead of 2025, and this then ended up as 1925 in the date.
QVariant has no operator< anymore
I've only noticed this when it was missing and I got the compilation error that this operator does not exist. In practice this was caused and means that you can't have a map<QVariant,...> anymore. I've used this in some places to store an id type, but QVariant allowed to stay flexible with making this an int or string depending on what was supplied. QVariant is often a work around for the missing template opportunities in Qt due to the moc/QObject/Signal and Slots not working with templates. I hope Qt7 fixes this.
QNetwork/HTTP2 runtime changes
This is something I've had to look into and try to understand. One recent addition to my RSSReader is better error management, e.g. I have added an interface to look at the various feeds that returned with an error. I've done this to better handle link rot and prior to this port things did run smoothly. But once I've started running in Qt6, I did see a bunch of new HTTP/2 errors showing up. The changes in QNetwork for Qt6 page is a good read to understand some of those.
First I do want to say that at least from my gut feeling, the error reporting has improved and I do see more issues now. Which helps me either fix this or disable said feed. One change with Qt6 is that QNetwork does not follow redirects anymore automatically. It often flags them as insecure redirect by default. There seems to be a setting to enable this again though as this thread from the Qt forums shows. And for the moment I'm not sure if I should do this. Maybe I should, but still then flag the redirect as an error, so that I'm able to replace it with the new url.
QNetwork seems to have matured a lot in Qt6, but also mostly in places where only very specialized code goes. Mostly the redirect errors should show up for normal users.
Join the Meeting C++ patreon community!
This and other posts on Meeting C++ are enabled by my supporters on patreon!