Hi,
I just start to write apps using QML, but I find the text display in StackView is a bit messy, even in the simplest case. Here’s the code:
main.qml
import QtQuick 2.2
import QtQuick.Controls 1.1
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
property Component t1: T1 {
onGotoPage: if (page === "T2") {
pageView.pop()
pageView.push(t2)
}
}
property Component t2: T2 {
onGotoPage: if (page === "T1") {
pageView.pop()
pageView.push(t1)
}
}
StackView {
id: pageView
anchors.fill: parent
focus: true
initialItem: t1
}
}
T1.qml
import QtQuick 2.0
Rectangle {
width: 100
height: 62
signal gotoPage(string page)
Text {
anchors.centerIn: parent
text: "hahahaha"
MouseArea {
anchors.fill: parent
onClicked: gotoPage("T2")
}
}
}
T2.qml
import QtQuick 2.0
Rectangle {
width: 100
height: 62
signal gotoPage(string page)
Text {
anchors.centerIn: parent
text: "appleeeeeeee"
MouseArea {
anchors.fill: parent
onClicked: gotoPage("T1")
}
}
}
It’s ok on desktop and android simulator. But on my phone(android 4.2.2), the initial page T1 is ok, then the weird T2
and go back to T1
It seems it’s not refreshed correctly. Is there any way to enforce correct display? Thanks.
↧