Results 1 to 7 of 7

Thread: qml listView key navigation not working setting focus: true

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2016
    Posts
    99
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default qml listView key navigation not working setting focus: true

    not able to navigate through list view using up/down arrows.... as far as I can tell setting focus: true should enable keyboard navigation?

    Qt Code:
    1. Component {
    2. id: msgDelegate
    3. Item {
    4. id: active_eventMsg
    5. anchors.left: parent.left
    6. anchors.leftMargin: 5
    7. anchors.right: parent.right
    8. anchors.rightMargin:5
    9. height: 30
    10. Keys.onUpPressed: listView.incrementCurrentIndex()
    11. Keys.onDownPressed: listView.decrementCurrentIndex()
    12. MouseArea {
    13. anchors.fill: parent
    14. onClicked: listView.currentIndex = index
    15. }
    16. Rectangle{
    17. id: id_rect
    18. anchors.top: parent.top
    19. anchors.left: parent.left
    20. anchors.leftMargin: 2
    21. width: id_col.width
    22. height: parent.height
    23. color: "#00000000"
    24. Text {
    25. color: active_eventMsg.ListView.isCurrentItem ? "white" : "black"
    26. anchors.fill: parent
    27. verticalAlignment: Text.AlignVCenter
    28. horizontalAlignment: Text.AlignLeft
    29. text: id;
    30. font.pixelSize: 18
    31. }
    32. }
    33. Rectangle{
    34. id: userName_rect
    35. anchors.top: parent.top
    36. anchors.left: id_rect.right
    37. anchors.leftMargin: 2
    38. width: userName_col.width
    39. height: parent.height
    40. color: "#00000000"
    41. Text {
    42. color: active_eventMsg.ListView.isCurrentItem ? "white" : "black"
    43. anchors.fill: parent
    44. anchors.leftMargin: 2
    45. verticalAlignment: Text.AlignVCenter
    46. horizontalAlignment: Text.AlignLeft
    47. text: userName;
    48. font.pixelSize: 18
    49. }
    50. }
    51. Rectangle{
    52. id: eventMsg_rect
    53. anchors.top: parent.top
    54. anchors.left: userName_rect.right
    55. anchors.leftMargin: 2
    56. width: eventMsg_col.width
    57. height: parent.height
    58. color: "#00000000"
    59. Text {
    60. color: active_eventMsg.ListView.isCurrentItem ? "white" : "black"
    61. anchors.fill: parent
    62. anchors.leftMargin: 2
    63. verticalAlignment: Text.AlignVCenter
    64. horizontalAlignment: Text.AlignLeft
    65. text: eventMessage;
    66. font.pixelSize: 18
    67. }
    68. }
    69. Rectangle{
    70. id: dateTime_rect
    71. anchors.top: parent.top
    72. anchors.left: eventMsg_rect.right
    73. anchors.leftMargin: 2
    74. width: dateTime_col.width
    75. anchors.right: parent.right
    76. height: parent.height
    77. color: "#00000000"
    78. Text {
    79. color: active_eventMsg.ListView.isCurrentItem ? "white" : "black"
    80. anchors.fill: parent
    81. anchors.leftMargin: 2
    82. verticalAlignment: Text.AlignVCenter
    83. horizontalAlignment: Text.AlignLeft
    84. text: dateTime;
    85. font.pixelSize: 18
    86. }
    87. }
    88. }
    89. }
    90. Rectangle {
    91. id: listView_rect
    92. radius: 8
    93. anchors.top: eventMsg_panel.bottom
    94. anchors.topMargin: 2
    95. anchors.bottom: parent.bottom
    96. anchors.bottomMargin: 65
    97. anchors.left:parent.left
    98. anchors.leftMargin: 5
    99. anchors.right:parent.right
    100. anchors.rightMargin: 6
    101. border{
    102. color: "black"
    103. width: 3
    104. }
    105. ScrollView{
    106. id: userEvent_scrollView
    107. anchors.fill: parent
    108. anchors.bottomMargin: 2
    109. anchors.topMargin: 2.5
    110. anchors.rightMargin: 2
    111. anchors.leftMargin: 2.5
    112. flickableItem.interactive: true
    113. ListView {
    114. id: listView
    115. anchors.fill: parent
    116. model: UserEventLog
    117. delegate: msgDelegate
    118. keyNavigationWraps: true
    119. //KeyNavigation: true
    120.  
    121. //Keys.onUpPressed: listView.incrementCurrentIndex()
    122. //Keys.onDownPressed: listView.decrementCurrentIndex()
    123.  
    124. highlight: Rectangle{
    125. width: parent.width
    126. radius: 7;
    127. color: "red"
    128. }
    129. focus: true
    130. orientation : "Vertical"
    131. snapMode: ListView.SnapToItem
    132. boundsBehavior: Flickable.StopAtBounds
    133. clip: true;
    134. }
    135. }
    136. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jfinn88; 27th September 2016 at 19:15.

Similar Threads

  1. Replies: 2
    Last Post: 16th May 2016, 23:50
  2. ListView - ListView communication
    By MarkoSan in forum Qt Quick
    Replies: 1
    Last Post: 30th October 2015, 10:18
  3. Replies: 11
    Last Post: 16th October 2015, 14:34
  4. QPushButton::setEnabled( true ) not working
    By unshaven in forum Newbie
    Replies: 1
    Last Post: 9th August 2012, 06:27
  5. Replies: 27
    Last Post: 13th September 2007, 09:01

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.