Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. TextInput value retain in QML?
Forum Updated to NodeBB v4.3 + New Features

TextInput value retain in QML?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.4k Views 3 Watching
  • 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

    How can I keep a value in a text input after a submit button clicked or changing different tabs in qml?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! Please explain what exactly the problem is. A TextInput will not change its text property unless you tell it to.

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

        @Wieland

        Hi
        I am beginner of qml.
        I try to design application form . In that page contain lot of textfield like name, age, address, etc. It consists of two pages. If i press next button the next page of the form will be appear. If i press previous button from 2 page, the textfield in the page 1 will be cleared. I need solution for the textfield entered data will appear without clearing.

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

          Hi,

          Just tried the sample program , where i took two pages
          first page is to enter username and password, clicking on submit, it navigates to another page.

          In another page i have back button, clicking on back button, navigates to first page where TextInput fields of first page are not cleared.

          Here are the two qml files

          main.qml

          import QtQuick 2.7
          import QtQuick.Window 2.2

          Window {
          id: windowObject
          visible: true
          width: 640
          height: 480

          Second
          {
              id: secondPage
              visible: false
              MouseArea{
                  anchors.fill: secondPage.backvisble
                  onClicked:
                  {
                      secondPage.visible = false
                      subWindowObject.visible = true
                  }
              }
          }
          
          
          Rectangle
          {
              id: subWindowObject
              x:100
              y:50
              width: 500
              height: 350
          
              Rectangle
              {
                  id: userNameLabelObject
                  width: 150
                  height: 50
                  color: "gray"
          
                  Text {
                      width: 50
                      height: 50
                      id: userNameText
                      text: qsTr("UsrName")
                      font.bold: true
                      font.pixelSize: 14
                      anchors.centerIn: userNameLabelObject
                  }
              }
          
              Rectangle
              {
                  id: textInputRectObject
                  width: 150
                  height: 50
                  border.color: "black"
          
                  anchors.left: userNameLabelObject.right
          
                  TextInput {
                      width: 50
                      height: 50
                      color: "orange"
                      id: textInputObject
                      font.bold: true
                      font.pixelSize: 14
                      anchors.centerIn: textInputRectObject
                  }
              }
          
          
          
          
              Rectangle
              {
                  id: passwordLabelObject
                  width: 150
                  height: 50
                  color: "gray"
                  anchors.top: userNameLabelObject.bottom
                  Text {
                      width: 50
                      height: 50
                      id: passwordText
                      text: qsTr("Password")
                      font.bold: true
                      font.pixelSize: 14
                      anchors.centerIn: passwordLabelObject
                  }
              }
          
              Rectangle
              {
                  id: textInputRectObject2
                  width: 150
                  height: 50
                  anchors.top: textInputRectObject.bottom
                  anchors.left: passwordLabelObject.right
                  border.color: "black"
          
                  TextInput {
                      width: 50
                      height: 50
                      color: "orange"
                      id: textInputObject2
                      font.bold: true
                      font.pixelSize: 14
                      echoMode: TextInput.Password
                      anchors.centerIn: textInputRectObject2
                  }
              }
          
              Rectangle
              {
                  x:200
                  y:200
                  id: submitButton
                  width: 150
                  height: 50
                  color: "skyblue"
                  Text {
                      id: submitText
                      font.bold: true
                      font.pixelSize: 14
                      anchors.centerIn: submitButton
                      text: qsTr("Submit")
                  }
              }
              MouseArea
              {
                  anchors.fill: submitButton
                  onClicked: {
                      secondPage.visible = true
                      subWindowObject.visible = false
                  }
              }
          }
          

          }

          Second.qml

          import QtQuick 2.7
          import QtQuick.Window 2.2
          import QtQuick.Controls 2.0

          Rectangle {

          id: secondRectObejct
          width: 500
          height: 500
          
          property alias backvisble: backButton
          
          
          Rectangle
          {
          
              id:backButton
              width: 150
              height: 50
              color: "skyblue"
              anchors.centerIn: parent
              Text {
                  id: backText
                  font.bold: true
                  font.pixelSize: 14
                  anchors.centerIn: backButton
                  text: qsTr("Back")
              }
          }
          

          }

          Hope the sample will help you.

          Thanks,

          Pradeep Kumar
          Qt,QML Developer

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

            @Pradeep Kumar

            Thank for your answer.

            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