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. TextInput focus issue
QtWS25 Last Chance

TextInput focus issue

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 747 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.
  • dheerendraD Offline
    dheerendraD Offline
    dheerendra
    Qt Champions 2022
    wrote on last edited by dheerendra
    #1

    I have big project with 100s of qml files. In one of the qml files we are using TextInput. TextInput gets focus only if I click.

    Just a sample code.

    Rectangle {
           TextInput{}
    }
    
    1. We are setting the focus. Does not work
    2. We tried using FocusScope. Did not work
    3. We tried using forceActiveFocus(..). Did not work.

    When we look at the activeFocus property, it gives me 'true'. But cursor does not come. I will not be able to enter text.

    If I click on the Rectangle or inside the TextInput, it immediately gets the focus. Otherwise it never.

    Any inputs on findout who is holding the focus ? Why it is not transferring the focus ?

    Dheerendra
    @Community Service
    Certified Qt Specialist
    http://www.pthinks.com

    ODБOïO 1 Reply Last reply
    0
    • dheerendraD dheerendra

      I have big project with 100s of qml files. In one of the qml files we are using TextInput. TextInput gets focus only if I click.

      Just a sample code.

      Rectangle {
             TextInput{}
      }
      
      1. We are setting the focus. Does not work
      2. We tried using FocusScope. Did not work
      3. We tried using forceActiveFocus(..). Did not work.

      When we look at the activeFocus property, it gives me 'true'. But cursor does not come. I will not be able to enter text.

      If I click on the Rectangle or inside the TextInput, it immediately gets the focus. Otherwise it never.

      Any inputs on findout who is holding the focus ? Why it is not transferring the focus ?

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      Hi,
      @dheerendra said in TextInput focus issue:

      We are setting the focus. Does not work

      I had similar problem, because was trying to set the focus too early,
      I just delayed that

      Component.onCompleted{
       myTxtInputId.focus  = true
      }
      

      instead of

      TextInput{
       id:  myTxtInputId
      focus:true
      }
      
      1 Reply Last reply
      3
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #3

        Thanks @LeLev. I appreciate your response. I will try & let you know the result.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        0

        • Login

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