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. QAbstractGraphicsShapeItem's perimeter to QPainterPath

QAbstractGraphicsShapeItem's perimeter to QPainterPath

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 215 Views
  • 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.
  • replR Offline
    replR Offline
    repl
    wrote on last edited by repl
    #1

    In my application, i am using many shapes which are directly or indirectly inherited the following classes
    QGraphicsEllipseItem
    QGraphicsPolygonItem
    QGraphicsRectItem

    Now i need to return its perimeter as shape() . How to compute any shape which inherited QAbstractGraphicsShapeItem.

    JonBJ 1 Reply Last reply
    0
    • replR repl

      In my application, i am using many shapes which are directly or indirectly inherited the following classes
      QGraphicsEllipseItem
      QGraphicsPolygonItem
      QGraphicsRectItem

      Now i need to return its perimeter as shape() . How to compute any shape which inherited QAbstractGraphicsShapeItem.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @repl
      Not that I am an expert here, but QPainterPath QGraphicsEllipseItem::shape() const
      etc. override shape() and return

      QGraphicsEllipseItem uses the rect and the pen width to provide a reasonable implementation of boundingRect(), shape(), and contains().

      and

      The default implementation calls boundingRect() to return a simple rectangular shape, but subclasses can reimplement this function to return a more accurate shape for non-rectangular items. For example, a round item may choose to return an elliptic shape for better collision detection. For example:

      so isn't that all you are supposed to use?

      1 Reply Last reply
      0
      • replR Offline
        replR Offline
        repl
        wrote on last edited by repl
        #3

        @JonB : boundingRect() returns complete area. But here i am looking for only perimeter.
        FOr exmaple: I draw a star shape star

        The QPen in painter draws the black outline & QBrush fills yellow color. Not my question is , Ho would i save the block outline [blck coloured outline ] as my painterpath ?

        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