V
V
Vi Vola2020-05-15 17:58:00
Qt
Vi Vola, 2020-05-15 17:58:00

How to animate GridView items in QML?

Most likely the question is addressed to QML specialists.
I am writing a small application using the qml/c++ bundle. And I use the models/views/delegates model in the implementation .

modelview-overview.png

That is, there is a certain GridView containing squares with some information that is taken from the model. The model is a C++ class inherited from QAbstractListModel . Well, the data is taken from a standard vector (std::vector) - one element of the vector is one element of the GridView .
I need to do some animation of the GridView items on mouse click. (I successfully did this by triggering the animation on the onClicked event for a specific GridView element). And a similar animation should be done when changing data in C++ code. And the actual question is how to generate an event when a vector element (std::vector) changes, so that it is called in the QML code for the corresponding GridView element ? And is it even possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory, 2020-05-15
@hakain

You need your model to generate a signal. After that, the handler for this signal in QML is done without any problems.
C++:
void someSignal(QString result);
QML:

Connections {
    target: model
    onSomeSignal: {
      if(result.length) {
        resultLabel.text = result;
      }
    }

  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question