Results 1 to 1 of 1

Thread: Listview drawing all delegates on hide

  1. #1
    Join Date
    Feb 2008
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Listview drawing all delegates on hide

    Hi all,
    I have a listview with a lot of items. Everything works fine as long as I don't click on the delegate to show me the details of the item
    in a different view on my stackview. Hidding the view with the listview in it triggers a full drawing of all delegates in the list even those
    which not have been displayed so far which makes my app hung up for more than 2 secs. Has anyone an idea what causes the redrawing?
    Happens on Android and iOS. On Android I'm using Qt5.2 on iOS 5.3
    My Listview with its delegate:
    Qt Code:
    1. ListView {
    2. id: listViewGrowers
    3. property int sortedCol: Constants.LIST_SORT_NAME_UP
    4. //delegate for tablets
    5. Component {
    6. id: growerDelegateTablet
    7. Rectangle {
    8. id:delegateContent
    9.  
    10. width: listViewGrowers.width
    11. height: visible?DisplayInfo.lineheight * 3:0
    12. color: "transparent"
    13. NavLine {
    14. id: line
    15. width: parent.width
    16. anchors.top: parent.top
    17. anchors.leftMargin: 0
    18. }
    19. MouseArea {
    20. anchors.fill: parent
    21. onClicked: {
    22. Qt.inputMethod.hide()
    23. growerListContent.visible = false
    24. growerItemSelected(model.modelData)
    25. }
    26. }
    27.  
    28. Rectangle {
    29. id: imageStars
    30. anchors.left: parent.left
    31. anchors.top: line.bottom
    32. width: parent.width * 0.2
    33. height: parent.height
    34. color: (listViewGrowers.sortedCol == Constants.LIST_SORT_STARS_UP || listViewGrowers.sortedCol == Constants.LIST_SORT_STARS_DOWN)?Theme.selected_col:"transparent"
    35. Image {
    36. asynchronous: true
    37. anchors.top: parent.top
    38. anchors.topMargin: DisplayInfo.lineheight * 0.5
    39. anchors.left: parent.left
    40. anchors.leftMargin: DisplayInfo.marginunit * 5
    41. fillMode: Image.PreserveAspectFit
    42. source: ("qrc:///icons/star_" + model.stars)
    43. height: DisplayInfo.lineheight * 0.8
    44. }
    45. }
    46. Rectangle {
    47. id: textGrower
    48. anchors.left: imageStars.right
    49. anchors.top: line.bottom
    50. width: parent.width * 0.4
    51. height: parent.height
    52. color: (listViewGrowers.sortedCol == Constants.LIST_SORT_NAME_UP || listViewGrowers.sortedCol == Constants.LIST_SORT_NAME_DOWN)?Theme.selected_col:"transparent"
    53. StyledText {
    54. text: model.name
    55. anchors.left: parent.left
    56. anchors.leftMargin: DisplayInfo.marginunit * 2
    57. anchors.top: parent.top
    58. anchors.topMargin: DisplayInfo.lineheight * 0.5
    59. }
    60. Component.onCompleted: {console.log("drawed: " + model.name)}
    61.  
    62. }
    63. Rectangle {
    64. id: imageGrowerLogo
    65. width: DisplayInfo.lineheight * 3.0
    66. height: parent.height
    67. anchors.left: textGrower.right
    68. anchors.top: line.bottom
    69. color: (listViewGrowers.sortedCol == Constants.LIST_SORT_NAME_UP || listViewGrowers.sortedCol == Constants.LIST_SORT_NAME_DOWN)?Theme.selected_col:"transparent"
    70. Image {
    71. asynchronous: true
    72. source: "qrc:///icons/logo_dummy"
    73. anchors.centerIn: parent
    74. sourceSize.height: DisplayInfo.lineheight * 2.8
    75. sourceSize.width: DisplayInfo.lineheight * 2.8
    76. }
    77. }
    78. Rectangle {
    79. id: region
    80. anchors.left: imageGrowerLogo.right
    81. anchors.top: line.bottom
    82. width: parent.width * 0.2
    83. height: parent.height
    84. color: (listViewGrowers.sortedCol == Constants.LIST_SORT_REGION_UP || listViewGrowers.sortedCol == Constants.LIST_SORT_REGION_DOWN)?Theme.selected_col:"transparent"
    85. StyledText {
    86. anchors.top: parent.top
    87. anchors.topMargin: DisplayInfo.lineheight * 0.5
    88. anchors.left: parent.left
    89. anchors.leftMargin: DisplayInfo.marginunit * 2
    90. text: model.region
    91. }
    92. MouseArea {
    93. anchors.fill: parent
    94. onClicked: {
    95. Qt.inputMethod.hide()
    96. console.log('region selected: ' + model.region)
    97. }
    98. }
    99. }
    100. Rectangle {
    101. id: addtionalnfo
    102. anchors.left: region.right
    103. anchors.top: line.bottom
    104. //width is listview filling
    105. width: parent.width - (imageStars.width + textGrower.width + imageGrowerLogo + region)
    106. height: parent.height
    107. color: "transparent"
    108. Image {
    109. id: bioFlag
    110. asynchronous: true
    111. source: "qrc:///icons/bio"
    112. anchors.top: parent.top
    113. anchors.topMargin: DisplayInfo.lineheight * 0.5
    114. anchors.left: parent.left
    115. anchors.leftMargin: DisplayInfo.marginunit * 2
    116. sourceSize.height: DisplayInfo.lineheight
    117. sourceSize.width: DisplayInfo.lineheight
    118. visible: model.bio
    119. }
    120. Image {
    121. id: newFlag
    122. source: "qrc:///icons/new"
    123. asynchronous: true
    124. anchors.top: parent.top
    125. anchors.topMargin: DisplayInfo.lineheight * 0.5
    126. anchors.left: bioFlag.right
    127. anchors.leftMargin: DisplayInfo.marginunit * 2
    128. sourceSize.height: DisplayInfo.lineheight
    129. sourceSize.width: DisplayInfo.lineheight
    130. visible: model.isNew
    131. }
    132. }
    133. }
    134. }
    135.  
    136. //delegate for phones
    137. Component {
    138. id: growerDelegatePhone
    139. Rectangle {
    140. width: ListView.width
    141. height: DisplayInfo.lineheight * 3
    142. }
    143. }
    144.  
    145. Connections {
    146. target: filterDialog;
    147. onApplied: {
    148.  
    149. filterItem.stars = filterDialog.selStars
    150. filterItem.onlyBio = filterDialog.selBio
    151. filterItem.onlyNew = filterDialog.selNew
    152. filterItem.regions = filterDialog.propregions
    153. growers.filterSettings(filterItem, textFilter.text)
    154. }
    155. }
    156. Connections {
    157. target: filterDialog;
    158. onCanceledFilter: {
    159. filterItem.stars = filterDialog.selStars
    160. filterItem.onlyBio = filterDialog.selBio
    161. filterItem.onlyNew = filterDialog.selNew
    162. filterItem.regions = filterDialog.propregions
    163. growers.filterSettings(filterItem, textFilter.text)
    164. }
    165. }
    166.  
    167. FilterGrower{
    168. id: filterItem
    169. }
    170.  
    171. width: DisplayInfo.isLowRes?parent.width:parent.width * 0.9
    172. anchors.top: header.bottom
    173. anchors.topMargin: DisplayInfo.lineheight
    174. anchors.bottom: growerListContent.bottom
    175. anchors.bottomMargin: DisplayInfo.lineheight * 4
    176. anchors.horizontalCenter: parent.horizontalCenter
    177. clip: true
    178.  
    179. model: growers.growers
    180. //delegate switched depending if tablet or smartphone
    181. delegate: DisplayInfo.isTablet?growerDelegateTablet:growerDelegatePhone
    182. //cacheBuffer: 60
    183. onDragStarted: {
    184. Qt.inputMethod.hide()
    185. }
    186. Component.onCompleted: {
    187. console.log("listviewcompleted")
    188. }
    189. }
    To copy to clipboard, switch view to plain text mode 

    Thx,
    Patrik


    Added after 4 minutes:


    Watching my code in a forum helped:
    Problem was the conditional height setting in my delegate. Removing it stopped the weired behaviour.
    patrik
    Last edited by patrikd; 17th June 2014 at 10:24.

Similar Threads

  1. Change properties of delegates in ListView
    By SteelBlade in forum Qt Quick
    Replies: 2
    Last Post: 14th June 2013, 12:23
  2. Models and Delegates
    By bgeller in forum Newbie
    Replies: 13
    Last Post: 4th March 2010, 05:46
  3. Trying to use delegates...
    By foahchon in forum Qt Programming
    Replies: 7
    Last Post: 28th August 2009, 08:17
  4. delegates
    By hgedek in forum Newbie
    Replies: 3
    Last Post: 24th October 2007, 20:00
  5. Delegates and Table
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 18th May 2006, 20:47

Tags for this Thread

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.