Equivalent to QGraphicsItem::ItemIgnoresTransformations flags in QtQuick 5
-
Hi,
We are working on a Diagram Editor in our compagny, so we migrate the UI from QGraphicsView to Qml/QtQuick. We are trying to implement zoom in/out capability. In our scene, we have some items of which size is not affected by zoom and some connection lines of which width remains fixed (2 px). Using QGraphicsView, we used QGraphicsItem::ItemIgnoresTransformations and QPen::setCosmetic to do it.
Is there an easy way to acheive that in QtQuick 5.5?
Note: This is a REAL blocker for us right now.
Thanks for you help.
-
Hi,
We are working on a Diagram Editor in our compagny, so we migrate the UI from QGraphicsView to Qml/QtQuick. We are trying to implement zoom in/out capability. In our scene, we have some items of which size is not affected by zoom and some connection lines of which width remains fixed (2 px). Using QGraphicsView, we used QGraphicsItem::ItemIgnoresTransformations and QPen::setCosmetic to do it.
Is there an easy way to acheive that in QtQuick 5.5?
Note: This is a REAL blocker for us right now.
Thanks for you help.
Hi @dzimiwine,
What have you used as a scene equivalent in QML ? And the child items which you load in that scene are derived from QQuickItem ?
-
Hi @dzimiwine,
What have you used as a scene equivalent in QML ? And the child items which you load in that scene are derived from QQuickItem ?
Hi @p3c0,
Thanks for your reply.
The scene itself is a regular Rectangle. Most of our items are Rectangles. The connection lines (actually cubic curve) derive from QQuickPaintedItem as its API is easy to use. We are trying to implement the zoom by changing the scale of the root rectangle. The scene is displayed inside a ScrollView which does not handle the scale on its contents (no scrollbars visible). -
Hi @p3c0,
Thanks for your reply.
The scene itself is a regular Rectangle. Most of our items are Rectangles. The connection lines (actually cubic curve) derive from QQuickPaintedItem as its API is easy to use. We are trying to implement the zoom by changing the scale of the root rectangle. The scene is displayed inside a ScrollView which does not handle the scale on its contents (no scrollbars visible).The scene is displayed inside a ScrollView which does not handle the scale on its contents (no scrollbars visible).
Yes it doesn't scale the contents. You will need to do that yourself if needed. You can just bind whatever calculation you have to the
scale
property of those child items.
Eg:Rectangle { scale: parent.scale * 0.5 }
and in case if you dont want to control the scaling of these children then just add condition.
Rectangle { scale: shouldScale ? parent.scale * 0.5 : 1.0 }
set this
shouldScale
to false. -
The scene is displayed inside a ScrollView which does not handle the scale on its contents (no scrollbars visible).
Yes it doesn't scale the contents. You will need to do that yourself if needed. You can just bind whatever calculation you have to the
scale
property of those child items.
Eg:Rectangle { scale: parent.scale * 0.5 }
and in case if you dont want to control the scaling of these children then just add condition.
Rectangle { scale: shouldScale ? parent.scale * 0.5 : 1.0 }
set this
shouldScale
to false.@p3c0
Note: Even though the size of an item should remain fixed, its position should match the scale.That was a bit my fear: doing all the calculation myself and deal with all the mapToItem stuff somehow.
As it is not natively supported, we will have no other choice but implementing it...too bad:)Thanks again for your reply
-
@p3c0
Note: Even though the size of an item should remain fixed, its position should match the scale.That was a bit my fear: doing all the calculation myself and deal with all the mapToItem stuff somehow.
As it is not natively supported, we will have no other choice but implementing it...too bad:)Thanks again for your reply
@dzimiwine AFAIK yes you will need to do it manually. May be someone else have some better ideas for how to do it in better way.
-
@dzimiwine AFAIK yes you will need to do it manually. May be someone else have some better ideas for how to do it in better way.