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 JSON in QML

Let's rewrite the weather demo in QML. You will find out how easy and elegant it is to write such an application in QML. Since the XML part is already covered in the previous chapter, we'll focus on parsing JSON this time.

First, create a new Qt Quick application project named Weather_QML. Keep the other settings as default, which means we use Qt Quick Controls. Remember to tick the checkbox of the Android kit.

Create a new QML file named Weather.qml to mimic the Weather class in the previous C++ code. This file is pasted here:

import QtQuick 2.3 import QtQuick.Controls 1.2 Rectangle { Column { anchors.fill: parent spacing: 6 Label { id: location width: parent.width fontSizeMode: Text.Fit minimumPointSize: 9 font.pointSize: 12 ...

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