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. How do I end activeFocus?
Forum Updated to NodeBB v4.3 + New Features

How do I end activeFocus?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 119 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.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by
    #1

    I have a TextInput and I am looking for a way to end activeFocus s/t once a user presses enter on the Qt virtualKeyboard activeFocus falls off of the TextInput. I am trying to use the selectAll() method and this is working but not the way I need it to work, here is my code:

    TextInput{
                id:inputItem
                text: "Enter text here"
    
                EnterKeyAction.enabled: inputItem.text.length > 0 || inputItem.inputMethodComposing
                EnterKeyAction.label: "Next"
    
                Keys.onReleased: {
                    if (event.key === Qt.Key_Return) {
                        activeFocus = false
                    }
                }
    
                onActiveFocusChanged: {
                    if(activeFocus) {
                        selectAll()
                        inputPanelContainer.textDisplay = inputItem.text
                    }
                }
    
                onDisplayTextChanged: {
                    inputPanelContainer.textDisplay = text
                }
            }
        }
    

    So, currently, the first time I click in the TextInput box the string is highlighted; however, the cursor just stays in the TextInput box even after I press enter. I want the focus to fall off of the TextInput each time the user enters their string s/t when they click the TextInput box again the string will highlight again, is this possible? Perhaps I am calling selectAll() in the wrong way or perhaps I am setting activeFocus incorrectly?

    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