Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    StackView different pages text display problem

    QML and Qt Quick
    1
    2
    871
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      culiubaicai last edited by

      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
      !http://i.imgur.com/CvT9nlp.jpg(appleeeeeeee)!
      and go back to T1
      !http://i.imgur.com/HWDjZCr.jpg(hahahaha)!
      It seems it's not refreshed correctly. Is there any way to enforce correct display? Thanks.

      1 Reply Last reply Reply Quote 0
      • C
        culiubaicai last edited by

        Finally I find the text is rendered OK when I add
        @renderType: Text.NativeRendering@

        to Text, don't know why the default Text.QtRendering doesn't work. Is it a bug?

        1 Reply Last reply Reply Quote 0
        • First post
          Last post