Results 1 to 2 of 2

Thread: Hide ListView items when not in bounds

  1. #1
    Join Date
    Oct 2013
    Posts
    142
    Thanks
    36
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Hide ListView items when not in bounds

    Is there a way to hide the elements which past the visible view in ListView?
    At the moment they go pass the header item and over another item before the header.

    Qt Code:
    1. ListView {
    2. id: searchList
    3. anchors.top: searchFieldBottomBorder.bottom
    4. anchors.topMargin: 20
    5. anchors.left: parent.left
    6. anchors.leftMargin: (parent.width - width) / 2
    7. width: searchField.width
    8. height: (body.height - title.height - searchField.height - 100)
    9. cacheBuffer: 0
    10. header: Rectangle {
    11. height: 50
    12. width: searchList.width
    13. color: "transparent"
    14. Text {
    15. text: "Select Location"
    16. color: "#ffffff"
    17. font.pixelSize: 18
    18. anchors.fill: parent
    19. verticalAlignment: Qt.AlignVCenter
    20. }
    21. }
    22. headerPositioning: ListView.OverlayHeader
    23.  
    24. delegate: Rectangle {
    25. height: 40
    26. width: searchList.width
    27. color: "transparent"
    28. Text {
    29. text: modelData
    30. color: "#ffffff"
    31. font.pixelSize: 18
    32. anchors.fill: parent
    33. verticalAlignment: Qt.AlignVCenter
    34. }
    35. MouseArea {
    36. anchors.fill: parent
    37. hoverEnabled: true
    38. cursorShape: Qt.PointingHandCursor
    39. }
    40. }
    41. }
    To copy to clipboard, switch view to plain text mode 

    Qt version: 5.6.2

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Hide ListView items when not in bounds

    Enable clipping

    Qt Code:
    1. clip: true
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    adutzu89 (20th February 2017)

Similar Threads

  1. Listview drawing all delegates on hide
    By patrikd in forum Qt Quick
    Replies: 0
    Last Post: 17th June 2014, 09:19
  2. Load more items to listview
    By matsukan in forum Qt Quick
    Replies: 1
    Last Post: 14th November 2012, 23:48
  3. How to set custom height for ListView & ComboBox items
    By rawfool in forum Qt Programming
    Replies: 1
    Last Post: 30th September 2011, 10:39
  4. Replies: 0
    Last Post: 18th February 2011, 08:24
  5. Custom Listview with all-time editable items
    By ivan.cukic in forum Qt Programming
    Replies: 5
    Last Post: 6th September 2006, 15:15

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.