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. Where is the point (0,0) (in item coordinates) of a QGraphicsPolygonItem ?
Forum Updated to NodeBB v4.3 + New Features

Where is the point (0,0) (in item coordinates) of a QGraphicsPolygonItem ?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 5 Posters 2.9k 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.
  • C Offline
    C Offline
    Cpowa
    wrote on last edited by
    #1

    Hello,

    When I build a QGraphicsPolygonItem like this:
    @poly << QPointF(0, -sqrt(12)) << QPointF(-2, 0) << QPointF(2, 0); //equilateral triangle
    QGraphicsPolygonItem polygon;
    polygon.setPolygon(poly);@
    Where is the ponit (0,0) in the item coordinates ?
    There is nothing in the doc.

    Thank you.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      As in whole Graphics View Framework, (0,0) is in the top left corner.

      (Z(:^

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Note quite, I seem to remember. (0,0) is the origin of the item, and the coordinate system is such that positive Y is under the (0,0) point and positive X to the right of the point. So far, we agree. However, you are allowed to use negative coordinates for drawing your item as well. That means that if you decide to draw a rectangle (-100, -100),(0,0), then you will have (0,0) in the lower right corner. Do not forget to return the correct bounding rect for your item.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          [quote author="Cpowa" date="1314778108"]
          Where is the ponit (0,0) in the item coordinates ?
          [/quote]

          What do you mean with that? Items have their local coordinate system.

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          1 Reply Last reply
          0
          • T Offline
            T Offline
            task_struct
            wrote on last edited by
            #5

            @Cpowa, as I understand from Andres answer QGraphicsPolygonItem has a bounding rectangle and 0,0 is at its lower right corner.

            "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

            • Linu...
            1 Reply Last reply
            0
            • D Offline
              D Offline
              dangelog
              wrote on last edited by
              #6

              There are no "corners". Items have their own local coordinate system, which is "infinite" in any direction (actually it's bounded by what you can represent with a qreal, but ...). (0, 0) is the origin, Y growns downwards and X grows rightwards (but of course you can apply a transformation).

              Software Engineer
              KDAB (UK) Ltd., a KDAB Group company

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                [quote author="task_struct" date="1314781082"]@Cpowa, as I understand from Andres answer QGraphicsPolygonItem has a bounding rectangle and 0,0 is at its lower right corner. [/quote]

                Then you misunderstood my post. My point was, that (0,0) is not a fixed point for any item. It is just the origin of the coordinate system, but because you are allowed to use negative coordinates, the actual drawing of the item could happen anywhere relative to this point. You can make (0,0) the upper left or the lower right corner of your item, but you can also make it the center, or draw you item so that (0,0) is completely outside your item. Bottom line: (0,0) can be anywhere. It is another question whether it should, of course.

                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