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. item translation with QTransform vs change item position

item translation with QTransform vs change item position

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.5k 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.
  • F Offline
    F Offline
    FrankiPL
    wrote on last edited by
    #1

    Hi all,

    I have a big QGraphicsPixmapItem in my QGraphicsView, so I have implemented some scene movement. I mean when I drag mouse - pixmap is moved so I can see different parts of the picute. I can do this two ways:

    1. by applying QTransform to the QGraphicsItem with translation set in the matrix
    2. by changing QGraphicsItem x,y position with .setPos() function.

    Is there some difference between these two mechanizm especially with performance?
    In fact I did this with QTransform, but would like to switch to simply setPos with the item if the performance of the app will not be affected.
    Maybe these two mechanizm uses the same method behind the scenes ?

    Best Regards
    Marek

    kshegunovK 1 Reply Last reply
    0
    • F FrankiPL

      Hi all,

      I have a big QGraphicsPixmapItem in my QGraphicsView, so I have implemented some scene movement. I mean when I drag mouse - pixmap is moved so I can see different parts of the picute. I can do this two ways:

      1. by applying QTransform to the QGraphicsItem with translation set in the matrix
      2. by changing QGraphicsItem x,y position with .setPos() function.

      Is there some difference between these two mechanizm especially with performance?
      In fact I did this with QTransform, but would like to switch to simply setPos with the item if the performance of the app will not be affected.
      Maybe these two mechanizm uses the same method behind the scenes ?

      Best Regards
      Marek

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @FrankiPL
      I'd use the simplest solution, i.e. QGraphicsItem::setPos(). QTransform resorts to a matrix to perform complex transformations in a single step so using it only for translation seems like overkill (performance shouldn't much suffer though).

      Is there some difference between these two mechanizm especially with performance?

      I don't know for sure.

      Read and abide by the Qt Code of Conduct

      F 1 Reply Last reply
      0
      • kshegunovK kshegunov

        @FrankiPL
        I'd use the simplest solution, i.e. QGraphicsItem::setPos(). QTransform resorts to a matrix to perform complex transformations in a single step so using it only for translation seems like overkill (performance shouldn't much suffer though).

        Is there some difference between these two mechanizm especially with performance?

        I don't know for sure.

        F Offline
        F Offline
        FrankiPL
        wrote on last edited by
        #3

        @kshegunov
        QGraphicsItem::setPos() is what I'm asking about.
        I have used QTransoform because except for translation I'm also scaling the picture, but probably you are right, I should try.

        Best Regards
        Marek

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Both are different concepts. setPos simply sets the position of the item within the scene. When you call setTransform, you modify the object from where it can be found.

          As for performances, you should benchmark both options.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • F Offline
            F Offline
            FrankiPL
            wrote on last edited by
            #5

            I was testing on my Linux box and I got impression that with setPos picture sometimes flicker, but app should work on Tablet and Phones where CPU is less powerful . So I guess I need to checki it, QTransform works fine on mobile devices.

            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