Firstly, a normal Qt widget cannot do this because of the way the painting engine operates (it's entirely 2D), and the way the layout managers work, so any solution is non-trivial.
The simplest way to do it, is to put the widget into a QGraphicsScene/View
as a QGraphicsProxyWidget
, and use the setTransform(const QTransform&, bool)
method to apply a transformation matrix.
However because the engine is still 2D, you will have to create a 3D transformation matrix describing the operation you want, then use projection to convert into a 2D matrix. It's not simple, but you can 'fake' the effect like the one you linked to by using the static method squareToQuad(const QPolygonF&, QTransform&)
- as the user 'rotates' the widget one vertical edge becomes smaller and moves towards the quad centre, whilst the opposite edge becomes bigger and moves towards the quad centre.