[Interest] Model/View delegate component common parts

Sina Dogru sinadooru at gmail.com
Tue Jul 5 14:13:02 CEST 2016


Hello everyone,

I have a custom c++ model class which inherits from QAbstractListModel. And
as a view I use GridView.
So GridView constructs as many components as
QAbstractListModel::rowCount(). But as a delegate I
use a complex component. With "complex" I mean that it has animations.

property bool animate: false
delegate: Rectangle {
    SequentialAnimation on color {
        running: view.animate
        loops: Animation.Infinite
        ColorAnimation { from: "blue"; to: "#33FFFF"; duration: 1200 }
        ColorAnimation { from: "#33FFFF"; to: "blue"; duration: 1200 }
    }
}

What I want to ask is, shall I move the common parts of the delegate one
layer up and use binding and
put up with the signal and slots mechanism overhead instead of constructing
unnecessary animation objects
for all model elements?

delegate: Rectangle {
    color: view.delegateColorAnimation
}
property bool animate: false
property color delegateColorAnimation
SequentialAnimation on delegateColorAnimation {
    running: animate
    loops: Animation.Infinite
    ColorAnimation { from: "blue"; to: "#33FFFF"; duration: 1200 }
    ColorAnimation { from: "#33FFFF"; to: "blue"; duration: 1200 }
}

I know signal and slots mechanism overhead is negligible but I am confused
because of the special
syntax for animation (Animation on property). Is there still a binding
mechanism running on the
background? Or is there any magic?

If there isn't any magic for this syntax, and updating the property still
relies on the binding mechanism,
probably the second option would be the better one?

Thank you,
Sina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160705/c1d02638/attachment.html>


More information about the Interest mailing list