Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Data transfer between item?
Forum Update on Monday, May 27th 2025

Data transfer between item?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
6 Posts 4 Posters 2.1k Views
  • 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.
  • E Offline
    E Offline
    eswar
    wrote on last edited by A Former User
    #1

    Page1.qml

    I have four textfields in page1 consists of name , age, DOB etc. The textfield are defined in inside the item. The page are loaded in using loader.

    Page2.qml

    i have four textfield like degree, course, coll, etc.The textfield are defined in inside the item. The page are loaded in using loader.

    page3 .qml

    I want to display the page1 and page2 entered text in page3 in list view. How can i acess the textfield entered data only in page3.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tirupathi Korla
      wrote on last edited by
      #2

      Hi,
      You can use the created files as items without using loader. If you want to use loader, this may help you
      http://doc.qt.io/qt-4.8/qml-loader.html. Check "Receiving signals from loaded items".

      1 Reply Last reply
      0
      • E Offline
        E Offline
        eswar
        wrote on last edited by
        #3

        @Tirupathi-Korla

        Thank you for your comments.

        I need to pass the textfield text only from one qml to other. I enter the age, name , DOB entered textfield data in page1 will be displayed in page3.qml. I need to transfer textfield enter data only in one qml to other qml.

        1 Reply Last reply
        0
        • Pradeep KumarP Offline
          Pradeep KumarP Offline
          Pradeep Kumar
          wrote on last edited by Pradeep Kumar
          #4

          Hi @eswar

          https://forum.qt.io/topic/72890/textinput-value-retain-in-qml

          continuation of other thread topic,

          You can use one property in Second.qml

          property alias adminInfo: text.text
          
          Rectangle
          {
          
              id:textInfo
              width: 150
              height: 50
              color: "skyblue"
              anchors.top: backButton.bottom
              Text {
                  id: text
                  font.bold: true
                  font.pixelSize: 14
                  anchors.centerIn: textInfo
              }
          }
          

          And in main.qml

              MouseArea
              {
                  anchors.fill: submitButton
                  onClicked: {
                      secondPage.visible = true
                      subWindowObject.visible = false
                      secondPage.adminInfo = textInputObject.text
                  }
              }
          

          Where u are sending the value from one main.qml file to another Second.qml file.

          Hope this works,

          Thanks,

          Pradeep Kumar
          Qt,QML Developer

          1 Reply Last reply
          2
          • E Offline
            E Offline
            eswar
            wrote on last edited by
            #5

            Hi @Pradeep-Kumar

            I will explain my concept clearly

            Here i have three qml files. The first.qml and second.qml have some textfields.

            first.qml

            item{

            name textfield
            age textfield
            DOB textfield

            }

            second.qml

            Item{

            college textfield
            course textfield
            dept textfield

            }

            third.qml
            {

            display the enter textfield value in any form.
            }

            main.qml

            rectangle{

            Inside the rectangle the load the first , second and third qml pages using stack view.

            }
            the two buttons next and back button appear in every page to switch qml views.

            If i move to third page, the all entered text field text will appear in any view. If i switching the pages, the enter data will be retain in textfield.

            how can i do it?

            1 Reply Last reply
            0
            • GTDevG Offline
              GTDevG Offline
              GTDev
              wrote on last edited by GTDev
              #6

              I would recommend to try separating the entered text (data) from the components that display them (textfields in pages 1/2 or plain text in page 3).

              As a first simple approach to achieve that, you can for example add properties for the data to your main.qml:

              Rectangle {
                id: main
              
                // myData property will be available in all sub-items of main
                property alias myData: dataItem 
              
                Item {
                  id: dataItem
                  property string name: ""
                  property string course: ""
                  // ... other data properties
                }
              }
              

              In your pages, you can then access the values using e.g. myData.name or myData.course.
              Just display the value in the third page, and make sure to save the value to these properties in the pages where you enter the data.

              This setup also ensures that you do not lose the data when pages are destroyed after you e.g. remove them from the StackView.

              Cheers,
              GT

              Senior Developer at Felgo - https://felgo.com/qt

              Develop mobile Apps for iOS & Android with Qt
              Felgo is an official Qt Technology Partner

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved