[Closed] ListView move items with animation. (no qml)



  • I have a list view that has n items , My requirement is that when i select an item in the list and move up or down,I need to provide an anmation effect For eg:

    item1
    item2
    item3
    item4
    item5
    item6

    If i select item5 and move/drag up then each item should shift one position down with animation and the current position should be empty until the item is dropped.

    How can i achieve something like this, It will be helpful if i get some examples.

    Thanks.



  • Hello,

    This is perhaps time to look at the QML :)



  • I would like to implement this without using qml. For animation QPropertyAnimation or QTimer might work.



  • Sure you can go without it.
    Just that it will take some time to implement.
    I don't know about your list, if it interact with the rest of your classical widget....
    But one admissible solution could be, if not, to encapsulate a QML in a QDeclarativeView and use it as a any other widget.
    .... still QML tought.



  • Perhaps you should google for "item views NG" then. It is an old research project for creating a new set of item views. The views in that framework (again: reseach, never officialy released!) are based on QGrapicsView. Animation is possible in there. The work done in this project was part of the basis of what you can now find in QML item views.

    But again: why is QML not an option? You can make only the list a QML view, in an otherwise QWidget based application.



  • [quote author="Andre" date="1348473731"]Perhaps you should google for "item views NG" then. [/quote]

    Yep, I checked out that, I downloaded the example from "here":http://qt.gitorious.org/qt-labs/itemviews-ng but couldn't get them working.

    bq. But again: why is QML not an option?

    To be honest I have to start with qml, dont have sufficient knowledge with that my bad :(

    Thanks for the help :-|



  • [quote author="Sam" date="1348484526"]
    [quote author="Andre" date="1348473731"]Perhaps you should google for "item views NG" then. [/quote]

    Yep, I checked out that, I downloaded the example from "here":http://qt.gitorious.org/qt-labs/itemviews-ng but couldn't get them working.
    [/quote]
    There is a compile error, but it is only in a test case, so you can simply disable the test.
    [quote]
    To be honest I have to start with qml, dont have sufficient knowledge with that my bad :([/quote]

    I think digging a bit into QML is going to be way less work than trying to program the animation yourself, even if you do that on top of ItemViewNG.



  • It's a good idea :)

    You can perform very smart result in a very short amount of time.
    Specially if you want to customize a listView.

    i would recommend you "this post":http://cdumez.blogspot.fr/2010/11/how-to-use-c-list-model-in-qml.html !

    Good luck



  • [quote author="Andre" date="1348485044"]
    I think digging a bit into QML is going to be way less work than trying to program the animation yourself, even if you do that on top of ItemViewNG.[/quote]

    Yes i have to look into that, But is there any way to use QPropertyAnimation on a listview item. I found "this":http://lists.trolltech.com/qt-interest/2002-02/thread01181-0.html discussion but not of much help as it uses QListViewItem- moveItems n all. But if there is some way I can get the co-ordinates or move the items then i can play with the animation.

    Or I Use a QWidget and a QVboxLayout and fake it to look like a QListView and then play with moving the widgets up and down ? Long way to go :-|

    [quote author="dmcr" date="1348486856"]It's a good idea :)

    You can perform very smart result in a very short amount of time.
    Specially if you want to customize a listView.

    i would recommend you "this post":http://cdumez.blogspot.fr/2010/11/how-to-use-c-list-model-in-qml.html !

    Good luck

    [/quote]

    Thanks for the help, but i couldnt get it working :(
    I got some Linker error related to QDeclarativeView.



  • Yes, you can animate properties. Simply use a Behaviour on on them.



  • Can you provide an example. I couldnt get any property for QListView or QStandardItem that could be used for animation, however I am using QStyledItemDelegate where i can get the position of each rect. using option.rect. I think i am going the wrong way to implement this.



  • Oh, sorry, my comment was aimed as ListView in QML, not QListView in Qt Widgets.

    No, in the widget world, I know of no ways to add animations to items.



  • No Problem at all,

    Thanks for your help :-)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.