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. Defining the element to focus when a text field is completed

Defining the element to focus when a text field is completed

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.6k 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.
  • Q Offline
    Q Offline
    qgil
    wrote on last edited by
    #1

    Some weeks ago I decided to use com.nokia.meego's "TextField":http://harmattan-dev.nokia.com/docs/library/html/qt-components/qt-components-meego-textfield.html?tab=1 element instead of Qt upstream "TextInput":http://doc.qt.nokia.com/4.7-snapshot/qml-textinput.html because the former had a convenient placeholderText property. Now someone had the good idea of jumping to the next text field when the user presses the Enter key. I see TextInput has a "onAccepted":http://doc.qt.nokia.com/4.7-snapshot/qml-textinput.html#onAccepted-signal signal to do just that, but this seems to be missing in TextField...

    Any suggestions on how to jump to the next field with a TextField. Advice on how to get placeholderText in a TextInput might be also useful. ;) Thanks!

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cpscotti
      wrote on last edited by
      #2

      Hi there Qgil,

      I came across that problem a few days ago too :D.

      @
      TextField {
      id: myField
      placeholderText: "Placeholder..."

      //...    
      
      Keys.onReturnPressed: {
          console.log("Enter pressed")
          settingsSheet.accept()//a parent settings sheet for example
          //or you could just set the next field's focus
      }
      

      }
      @

      I found the solution at QmlComponentGallery's "TextInputPage.qml" source file. That file's the best documentation for this sort of thing :D

      cpscotti.com/blog/ - Used when I need to kill some time at work :D

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qgil
        wrote on last edited by
        #3

        That did it. QML Keys element, another thing we have learned today. ;) Thank you very much!

        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