Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMatrix vs QTransform
Forum Updated to NodeBB v4.3 + New Features

QMatrix vs QTransform

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 6.6k Views 1 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.
  • X Offline
    X Offline
    xtingray
    wrote on last edited by
    #1

    Hello,

    Currently I'm porting and cleaning old code from my application.
    As QMatrix is already deprecated, I want to replace it using the
    QTransform class.

    This is a little example about what I'm planning:
    @
    // Old code
    QMatrix m;
    m.translate(point.x(), point.y());
    m.scale(-1.0, 1.0);
    m.translate(-point.x(), -point.y());
    item->setMatrix(m, true);
    @

    @
    // New code
    QTransform transform;
    transform.translate(point.x(), point.y());
    transform.scale(-1.0, 1.0);
    transform.translate(-point.x(), -point.y());
    item->setTransform(transform);
    @

    I would like to read about previous experiences doing this
    kind of operations. Suggestions? recommendations?

    Thanks!


    Qt Developer

    1 Reply Last reply
    0
    • M Offline
      M Offline
      minimoog77
      wrote on last edited by
      #2

      In the end both are matrices.

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xtingray
        wrote on last edited by
        #3

        Well, I started to replace the code and in some points the "usual" behavior is not the same. I guess I will have to spend some time dealing with this.

        Theoretically both are matrices... but in practice and after my first try I'm not so sure at all :P


        Qt Developer

        1 Reply Last reply
        0
        • M Offline
          M Offline
          minimoog77
          wrote on last edited by
          #4

          And where is the different behavior?

          I am looking at the documentation and I can see only one difference betweet this two.

          QMatrix has m11, m12, 0, m21, m22, 0, dx, dy, 1.
          QTransform is m11, m12, m13, m21, m22, m23, m31, m32, m33.

          Notice the difference, in the QMatrix m13 and m23 are always 0. These members are used when doing projection.

          So, final, with QMatrix you can't define projection transformation.

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xtingray
            wrote on last edited by
            #5

            As feature of my app, I wrote a plugin to allow scaling for QGraphicsItems using mouse events. With QMatrix the transformation looks smooth. When I tried to use QTransform (as in my first post), the effect was ugly (slow, discontinuous). I guess I'm missing something.

            In case you want to see something, here is the code (working with QMatrix for now):
            http://gitorious.org/tupi/tupi/trees/master/src/plugins/tools/selecttool

            Going to the point (line 177):
            http://gitorious.org/tupi/tupi/blobs/master/src/plugins/tools/selecttool/nodemanager.cpp

            Any advice is very welcome.


            Qt Developer

            1 Reply Last reply
            0
            • M Offline
              M Offline
              minimoog77
              wrote on last edited by
              #6

              I think it's time for bug report. I don't see why there is performance problems with scaling.

              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