Book Image

QT5 Blueprints

By : Symeon Huang
Book Image

QT5 Blueprints

By: Symeon Huang

Overview of this book

Table of Contents (17 chapters)
Qt 5 Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Tweaking the categories


This application is still incomplete. For example, the news view won't change at all after you click on the other categories. In this stage, we're going to work this out and make it more beautiful.

What we need to do is add MouseArea to CategoriesDelegate. This element is used to deal with a variety of mouse interactions, including clicking. The new CategoriesDelegate.qml file's code is pasted here:

import QtQuick 2.3

Rectangle {
  id: delegate
  height: 80

  Text {
    id: title
    anchors { left: parent.left; leftMargin: 10; right: parent.right; rightMargin: 10 }
    anchors.verticalCenter: delegate.verticalCenter
    text: name
    font { pointSize: 18; bold: true }
    verticalAlignment: Text.AlignVCenter
    wrapMode: Text.WordWrap
  }

  MouseArea {
    anchors.fill: delegate
    onClicked: {
      categories.currentIndex = index
      if(categories.currentUrl == url)
      newsModel.reload()
      else
      categories.currentUrl = url
    }
  }
}

As you can...