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. HowTo resize Subclasses of QGraphicsItem
Forum Updated to NodeBB v4.3 + New Features

HowTo resize Subclasses of QGraphicsItem

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

    HowTo resize Subclasses of QGraphicsItem?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dguimard
      wrote on last edited by
      #2

      maybe by using the prepareGeometryChange in your overrided method resize and then setting the new QSizeF , the update is then done automatically, maybe forcing it will not hurt

      1 Reply Last reply
      0
      • I Offline
        I Offline
        Immii
        wrote on last edited by
        #3

        You can use update() function this should do the job.
        void QGraphicsItem::update ( const QRectF & rect = QRectF() )
        it can be done calling prepareGeometryChange() with boundingRect(), I hope it should do the job ( I have never tested this though)

        1 Reply Last reply
        0
        • B Offline
          B Offline
          baysmith
          wrote on last edited by
          #4

          Assuming you mean "How do I create a resize-able custom QGraphicsItem?", the subclass needs to handle the mouse events to process a press-move-release sequence as a resize operation. During the operation, call prepareGeometryChange() and change the value which will be returned by the boundingRect().

          Nokia Certified Qt Specialist.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sahab
            wrote on last edited by
            #5

            [quote author="Bradley" date="1293081440"]Assuming you mean "How do I create a resize-able custom QGraphicsItem?", the subclass needs to handle the mouse events to process a press-move-release sequence as a resize operation. During the operation, call prepareGeometryChange() and change the value which will be returned by the boundingRect().[/quote]

            Well. This change the bounding rect of item. But the size of content is still the same. I need to resize content too within the new bounding rectangle.

            Thx.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              baysmith
              wrote on last edited by
              #6

              Yes, I was assuming that the custom item was painting its contents relative to the size of the bounding rectangle.

              Nokia Certified Qt Specialist.

              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