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. Resize a QGraphicsItem into a QGraphicsScene

Resize a QGraphicsItem into a QGraphicsScene

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 9.1k 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
    candidinho
    wrote on last edited by
    #1

    Hi,
    Can I resize with the mouse a QGraphicsPoligonItem into a QGraphicsView/QGraphicsScene?
    I don't know the way to do it.
    What functions do i have to reimplement?

    Thanks.

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      Here's one way to do it:

      Make your item selectable (setFlag())

      If the item is selected, have your custom item class paint a resize handle in each corner and edge

      In your custom item class, override the mousePress(), mouseMove(), and mouseRelease() virtual functions.

      In the mousePress() function add code to check if the mouse press is over one of the handles. If it is set a flag that says you are in "resize mode".

      In the mouseMove() function, if you are in "resize mode" then resize (and maybe reposition) your item as determined by the moved amount. Remember to call prepareGeometryChange() to ensure the item gets repainted.

      In the mouseRelease() function flag that you are no longer in "resize mode".

      HTH.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      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