Please nominate your Qt Champions for 2021!

TextInput focus issue

  • Qt Champions 2017

    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 {
    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 ?

  • 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

     myTxtInputId.focus  = true

    instead of

     id:  myTxtInputId

  • Qt Champions 2017

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

Log in to reply