When something happens to a station in the C++ part of the program, the corresponding QML item shall be modified. I got inspiration from a post on Andrew Jones' blog, regarding QML/C++ interactions using signals/slots.
Train::move() will trigger signal that will be caught by the QML part and update the map.
- A train enters a station
- A signal is trigged by train::move(), containing the station name, the train name and a description of the event
- A slot in the QML part recieves the signal and extracts the information.
- The corresponding QML item is updated
- The first will always contain the name of the station that is changing
- The second parameter will define what has happened (in this case: "train arrival")
- The third parameter will define any other items/objects (in this case, the train name)
In this case, I'll let the train::runningToOpeningState() emit a signal:
stationChangedSignal("LundC", "train arrival", "Hedy_Lamarr")
This signal will tell the QML part that a train named "Hedy_Lamarr" has arrived to the station LundC".
The current commit, 1c198ff, has introduced a signal without any parameters. I still have some problems parsing a signal containing qVariant data to the QML javascript. More about that in the next blog post.
No comments:
Post a Comment