Results 1 to 4 of 4

Thread: QGraphicsView - resize items on graphicsview resize -> calculate new positions

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2011
    Posts
    26
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default QGraphicsView - resize items on graphicsview resize -> calculate new positions

    Hey Guys,

    I am using a GraphicsView with a GraphicsScene which i added a PixmapItem....
    The QGraphicsPixmapItem is treated as my background item on Z-value "0" on Z-value "1" i have several other pixmapItems.

    My Problem:
    When i resize the whole program the QGraphicsView also resizes and so the Background item should be resized (what works fine) - it is just a *.scaled() Pixmap where scaled() gets the current size of the GraphicsView.
    Now i have to reposition the items on Z-value "1" to match the "same" position as before on the underlaying pixmap

    My current Solution:
    My current solution is not correct becauze the repositioning does "not work" - it's not exact .. (for the Background PixmapItem i used Qt::KeepAspectRatio)
    I saved the original size of the background Pixmap and the position of each Item for that "base size"
    On resizing i calculate the new x and y coordinates by referring to the old width/height of the Background Pixmap

    This means:
    NewWidth/oldWidth * oldX-Coordinate = NewX-Coordinate
    NewHeight/oldHeight * oldY-Coordinate = NewY-Coordinate

    Anyway .. it's "kinda" working but not exact (i thought it would work better that way ^^)

    Anybody an idea how it is possible to calculate that more precisely?? - Would be really lovely
    Thanks =)

  2. The following user says thank you to shock for this useful post:


Similar Threads

  1. Replies: 7
    Last Post: 1st December 2011, 16:24
  2. Replies: 1
    Last Post: 9th May 2011, 20:45
  3. How to resize the Items in FormLayout
    By sudhansu in forum Qt Programming
    Replies: 12
    Last Post: 4th December 2009, 06:34
  4. Replies: 2
    Last Post: 22nd January 2008, 16:10
  5. getting QGraphicsView to resize
    By MrGarbage in forum Qt Programming
    Replies: 1
    Last Post: 22nd January 2008, 03:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.