How to show different data in qml depending on backend objects
-
Let's say I have my gui running on a remote vehicle controller with a screen. I want to be able to show different views/data to the user depending on what vehicle I am driving. I am able to use the same controller to drive a car, air plane and submarine. But I want to draw a canvas in qml when connected to the car and show a text when connected to air plane and show a different text when connected to the submarine. Those "vehicles" will be different objects in the back-end.
The way I achieve this currently is using if-else statements in qml, but this is not feasible as the number of vehicles grows.
Is there a way to achieve this mechanism using models instead of using if-else?Thanks
-
use file selectors for showing completely different UI
https://doc.qt.io/qt-5/qfileselector.html#adding-selectorsYou can also add extra selectors at runtime for custom behavior. These will be used in any future calls to select(). If the extra selectors list has been changed, calls to select() will use the new list and may return differently.