Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QTextField focus issue in QML
Forum Updated to NodeBB v4.3 + New Features

QTextField focus issue in QML

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 2.1k Views 1 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.
  • S Offline
    S Offline
    saravanavelu39
    wrote on last edited by
    #1

    Hi friends,,

         I have used two text field,,if i click the button means that time two text field is visible,,but it is not foucsed in the first text field and cursor also not visible,, how to focus in the first text field and cursor visible in the text field in the first time,,so please give me some suggesstion,,
    

    Thanks,,

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Set focus to true for the first TextField.

      157

      1 Reply Last reply
      0
      • S Offline
        S Offline
        saravanavelu39
        wrote on last edited by
        #3

        Hi,

         I give the Focus to true in the text field,,but first time cursor is not focused on the first text field,,If i click the text field means after every time it focused in the text field,,but First time it's not focused,,this is the problem,,please give me the suggesstion,,
        

        Thanks

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          Is there any other Item that takes the focus away ?
          May be you should try setting the focus in Component.onCompleted handler.

          157

          1 Reply Last reply
          0
          • Pradeep P NP Offline
            Pradeep P NP Offline
            Pradeep P N
            wrote on last edited by
            #5

            Hi,

            Try this, try to set the focus of second field only when first is filled,

            TextInput {
            id: passwordField
            focus:true
            cursorPosition: TextInput.AlignHCenter // Align as needed
            MouseArea{ // If Needed
            anchors.fill: parent
            onClicked: {
            passwordField.forceActiveFocus()
            }
            }

            }

            TextInput {
            id: passwordField1
            focus: (passwordField.text !== "")
            cursorPosition: TextInput.AlignHCenter // Align as needed
            MouseArea{ // If Needed
            anchors.fill: parent
            onClicked: {
            Qt.inputMethod.show()
            clear_field(false,true,true,false)
            passwordField1.forceActiveFocus()
            }
            }
            onActiveFocusChanged:{ // Focus Change Function if needed
            if(passwordField1.focus) {
            if(passwordField.textValue == "") {
            passwordField.forceActiveFocus()
            }
            }
            }
            }

            Pradeep Nimbalkar.
            Upvote the answer(s) that helped you to solve the issue...
            Keep code clean.

            1 Reply Last reply
            2

            • Login

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