QML Automotive Cluster Interface
-
Hi everyone!
I started learning Qt and QML with a simple (and orrible :D) project of an Automotive Cluster Instrument interface. Below you can find the code for my project:
Automotive Cluster Interface Project
I'm struggling trying to place the needle.png image right on the same position as the guideline (CircularGauge.qml). I tried also the rotation (commented in the code) but I can't find the correct value of the rotation and the correct position of the needle. The result I have obtained is in the pic below:
I have also implemented some logic with C++ code trying to animate the needle when the key "W" and "S" are pressed, just like a real car, simulating the acceleration and the deceleration. I think that the logic should be correct, but I can't connect this code to QML to control the animation. The logic is implemented in the C++ class (ControlLogic.h, ControlLogic.cpp).
I want first to get the right position of the needle and then add an animation that moves with the control logic implemented. I also asked ChatGPT to help on this topics but it give me always the same incorrect answer. Any advice is welcome, also some tips to improve the code.
Thank you everyone!
-
Had a quick at your code.
engine.rootContext()->setContextProperty("controlLogic", &controlLogic);
controlLogic is visible to your qml files. But nowhere it is applied. Maybe use Connections inside your QML files to catch signals from controlLogic to make control changes.