[Qt-qml] Finding the coordinates of an item in a (Grid)View

mathias.malmqvist at nokia.com mathias.malmqvist at nokia.com
Tue Nov 2 21:00:37 CET 2010


Hi Pertti, 

Maybe you've already found a solution to your problem. If not, I think
your should look into the posibility of re-parenting the item you click 
on, out of the view before you move it. You can do this by giving the
item a new state and in it define a ParentChange. If this upsets the
grid you can make the grid item double-layered and only reparent 
the inner layer while the grid still manages the outer.

Hope this helps.


Cheers
Mathias

________________________________________
From: qt-qml-bounces at trolltech.com [qt-qml-bounces at trolltech.com] On Behalf Of ext Pertti Kellomäki [pertti.kellomaki at nokia.com]
Sent: Thursday, October 21, 2010 10:37 AM
To: qt-qml at trolltech.com
Subject: [Qt-qml] Finding the coordinates of an item in a (Grid)View

I have a small problem, maybe someone on the list can help.

I have an application with two views. In the first view, there are a
number of items displayed in a GridView. In the second view there is
just one item with some text beside it. What I am trying to accomplish
is a smooth transition between two views. When an item is clicked in the
first view, the selected item should slide to the left, and the rest of
the items should fade away.

The attached files contain a minimal implementation I have come up with.
The only problem is that I cannot figure out how to start the animation
of the selected item in the correct place, as indicated in the onClicked
handler in the code. In other words, I need to find the coordinates of
the selected item in the application's coordinate system. It seems that
Item::mapToItem() should do the job, but I have not found a way to use
it from QML without going via C++.

It is certainly possible that there is a much better way to accomplish
the same effect in QML. If so, please show me the error in my ways.
--
Pertti





More information about the Qt-qml mailing list