Results 1 to 2 of 2

Thread: How to shift focus from one text box to another?

  1. #1
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default How to shift focus from one text box to another?

    The code creates two input text boxes:

    Qt Code:
    1. import QtQuick 1.0
    2.  
    3. Column
    4. {
    5. width: 500
    6. height: 200
    7.  
    8. Text
    9. {
    10. id: userInfoTextA
    11. focus: false
    12. text: "Enter a value from 0 to 10:"
    13. }
    14.  
    15. TextInput
    16. {
    17. id: userInputA
    18. focus: true
    19.  
    20. anchors.left : userInfoTextA.right
    21. anchors.leftMargin : 20
    22.  
    23. validator: IntValidator { bottom:0; top: 20 }
    24.  
    25. Keys.onReturnPressed:
    26. {
    27. console.log (userInputA.text)
    28. }
    29. }
    30.  
    31. Text
    32. {
    33. id: userInfoTextB
    34. focus: false
    35. text: "Enter a value from 10 to 20:"
    36. }
    37.  
    38. TextInput
    39. {
    40. id: userInputB
    41. focus: true
    42.  
    43. anchors.left : userInfoTextB.right
    44. anchors.leftMargin : 20
    45.  
    46. validator: IntValidator { bottom:0; top: 20 }
    47.  
    48. Keys.onReturnPressed:
    49. {
    50. console.log (userInputB.text)
    51. }
    52. }
    53. }
    To copy to clipboard, switch view to plain text mode 

    In the output window the focus, by default, is set to the text box A. How should I move the focus to text box B by:
    - Keyboard

    and

    - Mouse
    ?

  2. #2
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Re: How to shift focus from one text box to another?

    From stackoverflow I came to know about key navigation for shifting focus through keyboard:
    http://qt-project.org/doc/qt-4.8/qml-keynavigation.html
    http://stackoverflow.com/a/19051908/462608

Similar Threads

  1. Set Focus on created QStandardItem and edit Text
    By blackbubblegum in forum Newbie
    Replies: 1
    Last Post: 29th February 2012, 10:52
  2. QComboBox - style sheet set text color non focus?
    By alan in forum Qt Programming
    Replies: 0
    Last Post: 12th March 2011, 23:31
  3. how to shift the focus to enter
    By gu574vo in forum Qt Programming
    Replies: 2
    Last Post: 27th October 2010, 22:45
  4. shift + key
    By jajdoo in forum Newbie
    Replies: 5
    Last Post: 22nd July 2010, 18:25
  5. Replies: 1
    Last Post: 5th August 2008, 20:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.