Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
QT5 Blueprints

You're reading from   QT5 Blueprints Design, build, and deploy cross-platform GUI projects using the amazingly powerful Qt 5 framework

Arrow left icon
Product type Paperback
Published in Mar 2015
Publisher
ISBN-13 9781784394615
Length 272 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Symeon Huang Symeon Huang
Author Profile Icon Symeon Huang
Symeon Huang
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Creating Your First Qt Application FREE CHAPTER 2. Building a Beautiful Cross-platform Clock 3. Cooking an RSS Reader with Qt Quick 4. Controlling Camera and Taking Photos 5. Extending Paint Applications with Plugins 6. Getting Wired and Managing Downloads 7. Parsing JSON and XML Documents to Use Online APIs 8. Enabling Your Qt Application to Support Other Languages 9. Deploying Applications on Other Devices 10. Don't Panic When You Encounter These Issues Index

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
    }

    Row {
      spacing: 20
      width: parent.width
      height: parent.height

      Label {
        id: temp
        width: parent.width / 2
        height: parent.height
        fontSizeMode...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime