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. flipping of items in the GraphicScene
Forum Updated to NodeBB v4.3 + New Features

flipping of items in the GraphicScene

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 4 Posters 3.6k 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.
  • J Offline
    J Offline
    Jaisan
    wrote on last edited by
    #1

    I need to draw items in Cartesian co ordinates which (0,0) starts from bottom left , and X grows right side and y -grows upward.But qt draws the items in scene in reverse way.
    what is the best way to flip the Y-axis.

    A 1 Reply Last reply
    0
    • J Jaisan

      I need to draw items in Cartesian co ordinates which (0,0) starts from bottom left , and X grows right side and y -grows upward.But qt draws the items in scene in reverse way.
      what is the best way to flip the Y-axis.

      A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      @Jaisan
      You can define the "origin point" of a QGraphicsItem through it's bounding rect:
      Create your own class derived from QGraphicsItem. You need to overload paint and boundingRect methods.
      The 0/0 position within the boundingRect you return is the origin for your item. To create an item that is 20 px wide and 10 px high, and has it's origin in the bottom right corner, return

      QRectF(QPointF(-20.0, -10.0), QPointF())
      

      Of course, all your painting within the item now has to happen within this rectangle, i.e. you have to draw on the negative side of the coordinate system.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jaisan
        wrote on last edited by
        #3

        Thanks for the reply.

        I need to flip the objects in Scene coordinates not with in boundingrect.
        for example I draw the item of 900x900 rectangle, now the (0,0 ) starts from top left and x grows right and y axis grows as downwards.

        My requirement is to draw the Y -axis from left bottom to grow upwards. and X-axis grows right side.

        O 1 Reply Last reply
        0
        • J Jaisan

          Thanks for the reply.

          I need to flip the objects in Scene coordinates not with in boundingrect.
          for example I draw the item of 900x900 rectangle, now the (0,0 ) starts from top left and x grows right and y axis grows as downwards.

          My requirement is to draw the Y -axis from left bottom to grow upwards. and X-axis grows right side.

          O Offline
          O Offline
          ofmrew
          wrote on last edited by
          #4

          @Jaisan Flipping when drawing on a widget you must first scale with x=1 and y=-1, then translate by an amount to move the top left corner down to the bottom left corner. You are flipping the entire scene. I have not tried it with GraphicsScene because it handles drawing.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jaisan
            wrote on last edited by
            #5

            You correct , as a permanent solution I would like to flip the entire scene co ordinate such that handling of objects with respect with will be easier.
            If we flip or offset the object alone then we need to do this tedious operation on every object handling .
            Like carrying a offset always in the co ordinates.

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi
              I think you can get it with
              view->scale(1, -1);

              https://stackoverflow.com/questions/10443894/how-to-set-qgraphicsscene-view-to-a-specific-coordinate-system

              However, it might have side effets.

              1 Reply Last reply
              1
              • J Offline
                J Offline
                Jaisan
                wrote on last edited by
                #7

                Thanks, it works as I expected.
                But the side effect is , able to view RubberBand but no effect on completion.

                mrjjM 1 Reply Last reply
                0
                • J Jaisan

                  Thanks, it works as I expected.
                  But the side effect is , able to view RubberBand but no effect on completion.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Jaisan
                  Hi
                  What about texts ?
                  The link talks about it might affect texts but im not sure in what way :)

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    Jaisan
                    wrote on last edited by
                    #9

                    Yes text were mirrored and also Rubberband selection is not working

                    J 1 Reply Last reply
                    0
                    • J Jaisan

                      Yes text were mirrored and also Rubberband selection is not working

                      J Offline
                      J Offline
                      Jaisan
                      wrote on last edited by
                      #10

                      any other way to fix thisin scene

                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        Jaisan
                        wrote on last edited by
                        #11

                        Text is fixed by Textitem->scale(-1,1) on paint() method.

                        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