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. Reimplement QGraphicsPathItem 's boundingRect() & shape() ?
Qt 6.11 is out! See what's new in the release blog

Reimplement QGraphicsPathItem 's boundingRect() & shape() ?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 1 Posters 1.3k 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.
  • O Offline
    O Offline
    opengpu
    wrote on last edited by
    #1

    i subclass a QGraphicsPathItem for custom lines and curves, as there are the control points for the curve which is out of the curve itself, and i wannt to dynamically click and move the control points, so i have to reimplement QGraphicsPathItem 's boundingRect() & shape().
    Now, (1) shape(): QPainterPath path = QGraphicsPathItem::shape(), then path.addRect() //add all the control points.
    (2) boundingRect(): QRectF rect = QGraphicsPathItem::boundingRect(), then rect = rect.united() //add all the control points.
    I debugged the shape() method seems work fine, BUT the boundingRect() method NOT RIGHT, after i click and move the controls point to another poisition. is it because the rect.united() i used?
    thank you!

    1 Reply Last reply
    0
    • O Offline
      O Offline
      opengpu
      wrote on last edited by
      #2

      can i simply return this->scene()->sceneRect() in the boudingRect()?
      i don't want to do like this cause my scene will be very large.
      but while i tested, it works fine, even while the lines and curves overlapped..

      1 Reply Last reply
      0
      • O Offline
        O Offline
        opengpu
        wrote on last edited by
        #3

        anyone met this kinda of problem?
        thanks:)

        1 Reply Last reply
        0
        • O Offline
          O Offline
          opengpu
          wrote on last edited by
          #4

          anyone help?
          thank you!

          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