O'Reilly logo

Qt 5 Blueprints by Symeon Huang

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Parsing RSS Feeds by XmlListModel

It's true that we now have categories, but they don't seem to be involved with RSS at all. Also, if you dig deeper, you'll find that the RSS feeds are in fact the XML documents. Qt already provides a useful type to help us parse them. We don't need to reinvent the wheel. This powerful type is the so-called XmlListModel element and it uses XmlRole to query.

Firstly, we need to expose the url role of categoriesModel to the main scope. This is done by declaring the property storing the model's current element, url, inside ListView. Then, we can add an XmlListModel element and use that url element as its source. Accordingly, the modified main.qml file is pasted here:

import QtQuick 2.3 import QtQuick.Window 2.2 import ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required