I'm a new qml programmer and I found my self in this problem that when I want to call a new page when clicked on a button it says:
TypeError: Cannot call method 'push' of null
I've tried everything I know to resolve this but still nothing.
Here is my code:
import QtQuick 2.0
import Ubuntu.Components 0.1
import "components"
MainView {
objectName: "mainView"
applicationName: "com.ubuntu.developer..EcoLover3"
automaticOrientation: true
width: units.gu(48)
height: units.gu(60)
PageStack {
id: pagestack
Component.onCompleted: push(page0)
Page {
id: page0
title: i18n.tr("Bem Vindo à aplicação do EcoLover" )
visible: false
Text {
id: entrada
text: qsTr("Caro Cliente, <br>aqui poderá contrloar os seus gastos de energia</br>")
}
Column {
anchors.margins: units.gu(3)
spacing: units.gu(3)
anchors.fill: parent
Image{
anchors.horizontalCenter: parent.horizontalCenter
source: "/home/diogo/ecoLover_teste2/components/Ecolover_com_stroke.png"
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
text: i18n.tr("Page one")
onClicked: pageStack.push(page1, {color: UbuntuColors.orange})
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
text: i18n.tr("Entrar no EcoLover")
onClicked: pageStack.push(Qt.resolvedUrl("Pagina_inicial.qml"))
}
}
}
Page {
title: "Rectangle"
id: page1
visible: false
property alias color: rectangle.color
Rectangle {
id: rectangle
anchors {
fill: parent
margins: units.gu(5)
}
}
}}}