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 ...