Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › Can't read AppTextInput value

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #23423

    Gabor

    I have 2 pages: HomePage.qml and Page2.qml. My goal is to enter a name on HomePage.qml and read the text field value from Page2.qml.

    My HomePage.qml:

    import QtQuick 2.0
    import Felgo 3.0
    
    Page {
        title: "Home"
    
        property alias propertyName: addName.text
    
        AppTextInput {
            id: addName
            width: dp(300)
            placeholderText: "Enter name:"
            anchors.centerIn: parent
        }
    }

    My Page2.qml:

    import QtQuick 2.0
    import Felgo 3.0
    
    Page {
        title: "Page 2"
    
        Loader {
            id: loadHome
            source: "HomePage.qml"
        }
    
        AppButton {
            id: load
            anchors.centerIn: parent
            onClicked: {
                console.log("Name: ", loadHome.propertyName)
            }
        }
    }
    

    Whenever I run the program I get a message:

    qml: Name: undefined

    How can I fix this?

    Thank you for your help.

    #23438

    Alex
    Felgo Team
    #23445

    Gabor

    Hi Alex,

    Thank you for your help.

    I made the recommended changes. The error message is gone, but loadHome.item.propertyName still doesn’t display anything. I only get

    qml: Name: without the actual name. On page 1 propertyName has a value (the correct name). What can I do to fix this?

    Thank you for your help.

    Gabor

    #23464

    Alex
    Felgo Team

    Hi,

    I am not sure what you are trying to do here, with loading one page inside another one. Anyway, here is an example of accessing the item in the Loader:

    import QtQuick 2.0
    import Felgo 3.0
    
    App {
      NavigationStack {
        Page {
          title: "Page"
    
          Column {
            width: parent.width
    
            Loader {
              id: loadHome
              width: parent.width
              height: item ? item.height : 0
              sourceComponent: homePageComponent
            }
    
            AppText {
              width: parent.width
              text: loadHome.item.propertyName
            }
          }
        }
      }
    
      Component {
        id: homePageComponent
    
        Item {
          width: parent.width
          height: addName.height
    
          // displayText also contains any text that is currently being composed by mobile dictionary features
          property alias propertyName: addName.displayText
    
          AppTextInput {
            id: addName
            width: parent.width
            placeholderText: "Enter name:"
            anchors.centerIn: parent
          }
        }
      }
    }

    Best,
    Alex

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded