(solved) animating a dynamically created qml component
-
Good morning,
I'm doing a custom table view object in C++. It's working but I'd like to improve how it's displayed. I created a component with animations attached to it. It creates the component and it displays correctly but the animations don't work.
@ myTableView
{
// provide an item the control can use for positioning. Exposed so visual effects can be attached
Component
{
id: gridPositionerId
Item
{
// Apply a NumberAnimation x property changes
Behavior on x
{
NumberAnimation
{
duration: 12000
easing.type: Easing.InOutQuad
}
}
Behavior on y
{
NumberAnimation
{
duration: 12000
easing.type: Easing.InOutQuad
}
}
}
}
// tell the view what to use for a positioner
positioner: gridPositionerId
}
@The instance of the positioner is created like this:
@ // create instance of positioner
positioner = qobject_cast< QQuickItem* >( _Positioner->create() );
if ( ! positioner )
{
qCritical() << "Cannot create a valid Positioner item";
return;
}
// set visual parent
positioner->setParentItem( this );
@I manage the position in the C++ code.
@positioner->setX( 10 );@
Any ideas why the behaviors aren't triggered?
The qdebug output doesn't show any errors -
Hi,
From the Docs "here":http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html#accessing-members-of-a-qml-object-type-from-c
bq. You should always use QObject::setProperty(), QQmlProperty or QMetaProperty::write() to change a QML property value, to ensure the QML engine is made aware of the property change.
So instead of using setX, try using one of the above.
-
You're Welcome :) Please mark the post as solved.