Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Equivalent to QGraphicsItem::ItemIgnoresTransformations flags in QtQuick 5
Forum Updated to NodeBB v4.3 + New Features

Equivalent to QGraphicsItem::ItemIgnoresTransformations flags in QtQuick 5

Scheduled Pinned Locked Moved QML and Qt Quick
quickcosmeticitemignorestran
7 Posts 2 Posters 2.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dzimiwine
    wrote on last edited by
    #1

    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.

    p3c0P 1 Reply Last reply
    0
    • D dzimiwine

      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.

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      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 ?

      157

      D 1 Reply Last reply
      0
      • p3c0P p3c0

        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 ?

        D Offline
        D Offline
        dzimiwine
        wrote on last edited by
        #3

        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).

        p3c0P 1 Reply Last reply
        0
        • D dzimiwine

          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).

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @dzimiwine

          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.

          157

          D 1 Reply Last reply
          0
          • p3c0P p3c0

            @dzimiwine

            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.

            D Offline
            D Offline
            dzimiwine
            wrote on last edited by
            #5

            @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

            p3c0P 1 Reply Last reply
            0
            • D dzimiwine

              @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

              p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              @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.

              157

              D 1 Reply Last reply
              0
              • p3c0P p3c0

                @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.

                D Offline
                D Offline
                dzimiwine
                wrote on last edited by
                #7

                @p3c0
                The cosmetic pen issue won't be easy to solve though.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved