You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I want is a guide to create custom classes with their functions, and then be able to import them and use their functions in a .qml file. I don't know where I have to add the source and header files for Qt to be able to detect them.
The text was updated successfully, but these errors were encountered:
Well that depends a bit on what you want to do and what you want to control. Best thing is to compare it something that is already there and put it in the same place. You can check src/UI/toolbar, src/QmlControls or src/FlightMap/Widgets to see some examples.
Everything you want to be able to call from a qml file should be an Q_INVOKABLE. Using an instance of a class in the qml file then allows you to call your functions or access variables.
Now for your custom classes, you can put them in a custom folder. Linking it to make it accessible in your qml file is then a bit a of a pain (my opinion^^). Easiest is to follow on what you see in other files. I would use something like src/FlightDisplay/OnScreenGimbalController.qml as an example, where you see how to include, create an instance, and then access its properties.
In general: Make sure you included the header and cpp files in all relevant places, which specifically includes CMakeLists in your custom folder, potentially as well src/QGCApplication.cc. If it is part of the active vehicle, then as well in the vehicle files.
I hope this gives you head start. It always took my a while to add something completely new.
What I want is a guide to create custom classes with their functions, and then be able to import them and use their functions in a .qml file. I don't know where I have to add the source and header files for Qt to be able to detect them.
The text was updated successfully, but these errors were encountered: