Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved]Highlight and PathView don't work, do not understand why !

[Solved]Highlight and PathView don't work, do not understand why !

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    YuFr
    wrote on last edited by
    #1

    Hi,

    First, I'm sorry for my english, I'm french ;)
    Then, Sorry again if the question is obvious, I began QML a few days ago ...

    So now, the problem !
    I want to make an Picture gallery, with a path view to select the picture displayed.
    I would like to center on my pathview the item which is currently displayed (the current index).
    I use the properties "preferredHighlightBegin" and "preferredHighlightEnd", with an highlight delegate, but it doesn't work, and I do not understand why ... So, here is my code :
    @
    //Delegate for displaying images in the gallery
    Component{
    id:imageDelegate
    Image {
    id:delegateContainer
    source:model.image
    height:imagesView.height
    width: imagesView.height*sourceSize.width/sourceSize.height
    smooth: true
    scale:PathView.scale;

        }
    }
    

    //Highlight delegate
    Component{
    id:highlightComponent
    Rectangle{
    id:highlightBox
    border.color: "red"
    border.width: 5
    color:"transparent"
    width: 200
    height: 200
    }
    }

    //The path view item
    PathView{
    id:imagesView;
    height: parent.height
    width: parent.width*0.80
    anchors.centerIn: parent

        model: imageModel;
        delegate:imageDelegate;
        highlight: highlightComponent
    

    //my Highlight should be in the middle of the root gallery (Rectangle which contain the pathview--)
    preferredHighlightBegin: rootGallery.width/2
    preferredHighlightEnd: rootGallery.width/2
    //I tried with PathView.StrictlyEnforceRange, the highlight was on the left, with ApplyRange it is on the Right
    highlightRangeMode: PathView.ApplyRange
    focus:true;
    currentIndex: Math.floor(imagesView.count/2);
    path: Path{
    startX: rootGallery.x; startY:rootGallery.y;
    PathAttribute{name: "scale";value: 0.25}
    PathLine{ x:imagesView.width/2; y:imagesView.height*0.80;}
    PathAttribute{name: "scale";value: 1}
    PathLine{ x:imagesView.width; y:0;}
    PathAttribute{name: "scale";value:0.25}
    }
    }
    @

    Thanks by advance for your answers !

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chuck Gao
      wrote on last edited by
      #2

      The preferred values must be in the range 0.0-1.0 for preferredHighlightBegin/End. So, set it to 0.5 is ok :D

      Chuck

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        YuFr
        wrote on last edited by
        #3

        Ok, I am stupid. I will wrote RTFM on a post-it and stick it on my screen ...
        Thanks a lot !

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved