How to scale QQuickItem in x or y direction only?
-
I'd actually like to mirror a QQuickItem via C++ interface, either vertically, horizontally or both.
Mirroring is just scaling with a factor of -1. But how do I apply the scaling by axis on a QQuickItem? There is a setScale, but it only take a single scaling factor.I do not to add any QML code for this, as it should work for any QML component my code runs on, no matter whether it's a standard component ("Rectangle", "Text") or my own QML component.
-
@Asperamanca to have a scaling on only 1 direction you have to use the
transform
property and aScale
object withxScale: -1
.There is no c++ API for it but you could do apply this to any object from C++ with a QQmlComponent instantiating a Scale object an then setProperty.
This will work on any Item/QQuickItem regardless if there are "standard" or your owns.