Results 1 to 5 of 5

Thread: QPathView shows an empty entry after incrementCurrentIndex

  1. #1

    Default QPathView shows an empty entry after incrementCurrentIndex

    Hi I am trying to create a path view. Please find below the attached sample code snippet. When ever i try to do an incrementCurrentIndex(), I get a empty field at the begining of the pathview and that empty entry is filled with next element when i do decrementCurrentIndex(). How can i make my pathview behave the same both during incrementCurrentIndex() and decrementCurrentIndex() ?

    Qt Code:
    1. import QtQuick 2.0
    2.  
    3. Item {
    4. width: 180
    5. height: 250
    6. PathView {
    7. id: list
    8. focus: true
    9. preferredHighlightBegin: 2/5
    10. preferredHighlightEnd: 3/5
    11. highlightRangeMode: PathView.ApplyRange
    12. Keys.onUpPressed: decrementCurrentIndex()
    13. Keys.onDownPressed: incrementCurrentIndex()
    14. model: 5
    15. delegate: Rectangle {
    16. id: wrapper
    17. border.width: 1
    18. border.color: "green"
    19. width: 180
    20. height: 40
    21. color: "steelblue"
    22. Text {anchors.centerIn: parent; text: index; font.bold: wrapper.PathView.isCurrentItem?true:false}
    23. }
    24. path: Path {
    25. id: path
    26.  
    27. startX: 90; startY: 20
    28. PathLine { x: 90; y: 40*(5)}
    29. }
    30. }
    31. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by rannamal; 30th November 2016 at 09:40.

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

    Default Re: QPathView shows an empty entry after incrementCurrentIndex

    Have you tried without the preferredHighlightRange?

    Cheers,
    _

  3. #3

    Default Re: QPathView shows an empty entry after incrementCurrentIndex

    Anda_skoa, Thanks for your response.

    Yes, Tried without preferredHighlightRange, but the response is same. I still have an empty entry towards the top when i incrementCurrentIndex().

    But when "highlightRangeMode" is set from "ApplyRange" to "StrictlyEnforceRange" I dont face this issue, the top entry gets filled up automatically, but I lose the advantage of "ApplyRange" over "StrictlyEnforceRange".

    Will there be any way to overcome this ? I want to use "ApplyRange" instead of "StrictlyEnforceRange" and still maintain same behavior of pathview during incrementCurrentIndex() and decrementCurrentIndex()

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPathView shows an empty entry after incrementCurrentIndex

    I tried this and what you are seeing is not an empty item but the item not fully fitting anymore an being placed on the other hand.

    Actually happens in both scroll directions but you weren't aware of it on the bottom side when scrolling up.

    I've modified your example a bit to visualize that

    Qt Code:
    1. import QtQuick 2.0
    2.  
    3. Item {
    4. width: 180
    5. height: 250
    6. PathView {
    7. id: list
    8. y: 20
    9. width: parent.width
    10. height: 5 * 40
    11.  
    12. focus: true
    13. preferredHighlightBegin: 2/5
    14. preferredHighlightEnd: 3/5
    15. highlightRangeMode: PathView.ApplyRange
    16. Keys.onUpPressed: decrementCurrentIndex()
    17. Keys.onDownPressed: incrementCurrentIndex()
    18. model: 5
    19. delegate: Rectangle {
    20. id: wrapper
    21. border.width: 1
    22. border.color: "green"
    23. width: 180
    24. height: 40
    25. color: "steelblue"
    26. Text {anchors.centerIn: parent; text: index; font.bold: wrapper.PathView.isCurrentItem?true:false}
    27. }
    28. path: Path {
    29. id: path
    30.  
    31. startX: 90; startY: 0
    32. PathLine { x: 90; y: 40*(5)}
    33. }
    34. }
    35.  
    36. Rectangle {
    37. anchors.fill: list
    38. color: "red"
    39. opacity: 0.3
    40. }
    41. }
    To copy to clipboard, switch view to plain text mode 
    The rectangle visualizes where the view's are actually is, you see that no matter which direction you scroll you have white space on the other end.
    I've moved the view a bit downwards as well so that the "overlap" is also visible on both sides.
    I've also modified the path so that is starts at the beginning of the view and extends to just the end of the view.

    Now try the same thing with preferredHighlightBegin and preferredHighlightEnd set to 0.5

    Cheers,
    _

  5. #5

    Default Re: QPathView shows an empty entry after incrementCurrentIndex

    Tried out your sample. Yes it behaves the same for increment and decrement. More over as you have pointed out if the preferredHighlightBegin and preferredHighlightEnd are set to the same value then I dont face any shift issues. Thanks for your efforts anda_skoa

Similar Threads

  1. QSqlQueryModel shows empty table with correct headers
    By Charlie42 in forum Qt Programming
    Replies: 0
    Last Post: 17th August 2015, 07:22
  2. Replies: 0
    Last Post: 29th April 2011, 09:02
  3. Replies: 2
    Last Post: 27th October 2010, 11:23
  4. QComboBox (model based) - provide an empty entry
    By antarctic in forum Qt Programming
    Replies: 0
    Last Post: 21st October 2009, 18:45
  5. Replies: 2
    Last Post: 17th July 2006, 14:52

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.