×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Feb 2012
    Posts
    130

    Getting X from flickable elements

    I posted this in the QT Beginner section but I'm getting no answers so I'm posting here.

    I have a Page that contains a Flickable element and in that element I have an Image and I allow left to right flicking only flickableDirection : Flickable.HorizontalFlick
    I use onFlickEnded: to set a text field to image1.x but it only ever returns the initial x location of the image, but I expect it to be the new x location of the image which is somewhere off of the screen after a flick is ended!

    Here is the code:
    Code:
    Page {
        id: mainPage
        Flickable {
            id: flickable1
            x: 0
            contentWidth: image1.width;   //It's a wide image, much wider than the screen
            onFlickEnded:   debugging.text = image1.x
            Image {
                id: image1
                fillMode: Image.PreserveAspectFit
                source: "Slide.jpg"
                sourceSize.width: 2000
                x: 10
    Whenever the image is flicked onFlickEnded sets debugging.text to 10 (the initial x value for the image). How do I work out which portion of the image is on the screen? How do I get the new x value?
    Note: above I left out a few irrelevant lines of code like the y-value etc. but I can post the full code if anyone wants. My target platform is Symbian.


    Thanks.

  2. #2
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    Re: Getting X from flickable elements

    Yes the debugging.text will always hold 10 as the x property of the image actually never changes.

    AFAIU, you can fetch the new x value for the visible area on the flickable element.
    Please try -
    onFlickEnded : flickable1.visibleArea.xPosition + 10 // + 10 so that it gives for the xpoistion on image instead of the entire flickable..

    (no idea if we can get it for the image directly hence the above workaround)

  3. #3
    Regular Contributor
    Join Date
    Feb 2012
    Posts
    130

    Re: Getting X from flickable elements

    Thankyou very much!
    So to understand this, I declared a static x property rather than initialising a dynamic x value? That makes sense but just checking that I have it right.
    I'll try using the visible area property.

Similar Threads

  1. Getting change in x in a Flickable element
    By CLTSchwarz in forum [Archived] Beginning Qt
    Replies: 3
    Last Post: 2012-05-17, 07:59
  2. Flickable is not stopping on page
    By AdnanShoukat in forum [Archived] Qt Quick
    Replies: 6
    Last Post: 2012-03-29, 10:49
  3. Flickable & PinchArea
    By chits in forum [Archived] Qt Quick
    Replies: 1
    Last Post: 2011-05-17, 17:53
  4. QML Flickable Element performance
    By cadlg in forum [Archived] Qt Quick
    Replies: 1
    Last Post: 2011-03-18, 01:57
  5. Flickable and MouseUp
    By alichino in forum [Archived] Qt Quick
    Replies: 3
    Last Post: 2011-03-13, 08:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×