Results 1 to 1 of 1

Thread: TableView with TableStyle ScrollBar

  1. #1
    Join Date
    Apr 2015
    Posts
    20
    Thanks
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: TableView with TableStyle ScrollBar

    Ok, I have most functionality but no touch or touch and drag. I can customize my scroll bar, I can click in it with a mouse or grab the handle with a mouse and all is well. I can flick the tableview area and the scrollbar handle will move along. But for the life of me I can't get the touch on scrollbar (analogous to mouse click) to make any change and I can't touch (click with finger) the handle and drag it. Any ideas?

    Thanks,
    Rich

    Qt Code:
    1. TableView {
    2. id: eventLogView
    3. anchors{left: parent.left; leftMargin: 30;
    4. top: filterInputFields.bottom; topMargin: 10
    5. right: parent.right; rightMargin: 60;
    6. bottom: footerSeparator.top;
    7. }
    8. frameVisible: false
    9. headerVisible: true
    10. alternatingRowColors: false
    11. horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
    12. verticalScrollBarPolicy: Qt.ScrollBarAlwaysOn
    13. clip: true
    14. sortIndicatorColumn: 0
    15. sortIndicatorOrder: Qt.DescendingOrder
    16. model: sqlELmodel
    17.  
    18.  
    19. style: TableViewStyle {
    20. id: tvStyle
    21. scrollToClickedPosition: true
    22. frame: Rectangle {
    23. width: 12
    24. anchors.fill: parent
    25. radius: width/2
    26. }
    27. scrollBarBackground: Rectangle {
    28. implicitWidth: 12
    29. color: "#DBDDDD"
    30. radius: width/2
    31. }
    32. handle: Rectangle {
    33. id: sbHandle
    34. color: "#2EA2EC"
    35. implicitWidth: 12
    36. radius: width/2
    37. anchors.top: parent.top
    38. }
    39. minimumHandleLength: 40
    40. handleOverlap: 0
    41.  
    42. decrementControl: Rectangle{
    43. visible: false
    44. }
    45. incrementControl: Rectangle {
    46. visible: false
    47. }
    48.  
    49. headerDelegate: Rectangle {
    50. width: txtHdr.width*1.4
    51. height: txtHdr.height*1.2
    52. clip: true
    53.  
    54. Row {
    55. anchors.fill: parent
    56. spacing: 10
    57.  
    58. Image {
    59. id: imgHdr
    60. anchors.verticalCenter: txtHdr.verticalCenter
    61. source: ((eventLogView.sortIndicatorOrder === Qt.DescendingOrder) ? "qrc:/assets/Images/Icon_Scroll_DownChevron.png" : "qrc:/assets/Images/Icon_Scroll_UpChevron.png")
    62. visible: ((eventLogView.sortIndicatorColumn === styleData.column) ? true : false)
    63. width: sourceSize.width*0.6
    64. height: sourceSize.height*0.6
    65.  
    66. MouseArea {
    67. anchors.fill: parent
    68. onClicked: {
    69. eventLogView.sortIndicatorColumn = eventLogView.getColumn(index)
    70. }
    71. }
    72. }
    73. Text {
    74. id: txtHdr
    75. leftPadding: 5
    76. text: styleData.value
    77. font.pixelSize: 19
    78. font.family: "NotoSans"
    79. elide: Text.ElideRight
    80. }
    81. }
    82. }
    83.  
    84. rowDelegate: Rectangle {
    85. id: tvRowDelegate
    86. height: 65
    87. width: parent.width
    88.  
    89. state: ((sqlELmodel.getExpanded(styleData.row)) ? "expanded" : "collapsed")
    90. states:
    91. [
    92. State {
    93. name: "collapsed"
    94. PropertyChanges { target: tvRowDelegate; height: 65; }
    95. },
    96. State {
    97. name: "expanded"
    98. PropertyChanges { target: tvRowDelegate; height: (sqlELmodel.getExpandedSL(styleData.row) === 0) ? 100 : (33*(sqlELmodel.getExpandedSL(styleData.row)/30) < 100) ? 100 : 33*(sqlELmodel.getExpandedSL(styleData.row)/30); }
    99. }
    100. ]
    101. MouseArea {
    102. anchors.fill: parent
    103. onClicked: {
    104. sqlELmodel.setExpanded(styleData.row, !sqlELmodel.getExpanded(styleData.row))
    105. timerRow = styleData.row
    106. sqlELmodel.refresh()
    107. timerPos.start();
    108. }
    109. }
    110. }
    111.  
    112. itemDelegate: Rectangle {
    113. id: eventItem
    114. width: parent.width
    115. height: 65
    116. color: "#ECEEEE"
    117.  
    118. Image {
    119. id: imgExp
    120. anchors.verticalCenter: txtItm.verticalCenter
    121. anchors{left: parent.left}
    122. source: ((sqlELmodel.getExpanded(styleData.row) ? "qrc:/assets/Images/Icon_Scroll_UpChevron.png" : "qrc:/assets/Images/Icon_Scroll_DownChevron.png"))
    123. visible: ((styleData.column === 2) ? true : false)
    124. width: sourceSize.width*0.6
    125. height: sourceSize.height*0.6
    126. }
    127. Text {
    128. id: txtItm
    129. leftPadding: 35
    130. anchors.verticalCenter: parent.verticalCenter
    131. text: ((styleData.row === -1) ? "" : getText(styleData.row, styleData.column, styleData.value))
    132. font.pixelSize: 19
    133. font.family: "NotoSans"
    134. width: ((styleData.column === 0) ? col1.width : ((styleData.column === 1) ? col2.width : col3.width - imgExp.width))
    135. elide: Text.ElideRight
    136. wrapMode: ((styleData.column > 1) ? TextEdit.WrapAnywhere : TextEdit.NoWrap)
    137. }
    138. Rectangle {
    139. width: parent.width
    140. height: 3
    141. color: "#FFFFFF"
    142. }
    143. }
    144.  
    145. function getText(row, col, txt) {
    146. if (txt.length < 1) {
    147. return ""
    148. }
    149. else {
    150. if (col === 0) {
    151. // This is UTC time created from milliseconds!
    152. var dt = new Date(txt)
    153. return formatDT(dt.toLocaleString(Qt.locale(), "MM/dd/yyyy hh:mm:ss AP"))
    154. }
    155. else if (col === 1) {
    156. return txt
    157. }
    158. else if (col === 2) {
    159. var cTxt
    160. cTxt = sqlELmodel.combineColumns(row, 2, 3)
    161. sqlELmodel.setExpandedSL(row, cTxt.length)
    162. if (!sqlELmodel.getExpanded(row)) {
    163. return txt
    164. }
    165. else {
    166. return cTxt
    167. }
    168. }
    169. else {
    170. return ""
    171. }
    172. }
    173. }
    174. }
    175.  
    176. TableViewColumn {
    177. id: col1
    178. title: qsTrId("Date/Time")
    179. role: "CreatedDateTime"
    180. movable: false
    181. resizable: false
    182. width: eventLogView.viewport.width * 0.30
    183. }
    184.  
    185. TableViewColumn {
    186. id: col2
    187. title: qsTrId("User")
    188. role: "UserName"
    189. movable: false
    190. resizable: false
    191. width: eventLogView.viewport.width * 0.20
    192. }
    193.  
    194. TableViewColumn {
    195. id: col3
    196. title: qsTrId("Event")
    197. role: "EventName"
    198. movable: false
    199. resizable: false
    200. // Leave some pad to scroll bar
    201. width: eventLogView.viewport.width * 0.45
    202. }
    203.  
    204. TableViewColumn {
    205. id: col4
    206. title: qsTrId("Event Detail")
    207. role: "EventDetail"
    208. movable: false
    209. resizable: false
    210. visible: false
    211. }
    212.  
    213. onSortIndicatorColumnChanged: {
    214. // Default sort descending on column change
    215. sortIndicatorOrder = Qt.DescendingOrder
    216. sqlELmodel.sortNewCol(sortIndicatorColumn)
    217. }
    218.  
    219. onSortIndicatorOrderChanged: {
    220. // Toggle sorting
    221. sqlELmodel.sortToggle(sortIndicatorOrder, sortIndicatorColumn)
    222. }
    223.  
    224. flickableItem.onContentYChanged: {
    225. if (getLastVisibleRow() <= currRow) {
    226. currRow = getLastVisibleRow()
    227. return;
    228. }
    229. currRow = getLastVisibleRow()
    230. if (currRow > (0.8 * rowCount)) {
    231. timerRow = currRow - 2
    232. if (sqlELmodel.fetch(false)) {
    233. timerPos.start()
    234. }
    235. }
    236. }
    237.  
    238. function getLastVisibleRow() {
    239. var height = 0;
    240. while (height < eventLogView.viewport.height) {
    241. height += 15;
    242. }
    243. return eventLogView.rowAt(parent.width/2, height)
    244. }
    245. }
    To copy to clipboard, switch view to plain text mode 


    Added after 22 minutes:


    I think I need to somehow set the interactive property since mouse works and touch does not but not sure where to do so.
    Last edited by rhb327; 31st July 2020 at 01:21.

Similar Threads

  1. Replies: 0
    Last Post: 4th August 2015, 10:12
  2. Replies: 1
    Last Post: 13th February 2012, 16:54
  3. ScrollBar
    By A9am in forum Newbie
    Replies: 5
    Last Post: 8th November 2011, 07:23
  4. ScrollBar
    By damodharan in forum Qt Programming
    Replies: 1
    Last Post: 11th February 2010, 15:50
  5. Scrollbar
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 31st October 2007, 08:33

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.