Results 1 to 2 of 2

Thread: QGraphicsItem and it's position at QGraphicsView

  1. #1

    Default QGraphicsItem and it's position at QGraphicsView

    I've got a problem with QGraphicsView and the stuff.

    What I wanna do, is to load an Image, display it and give user the ability to move it around and zoom in/zoom out. Here is what are my assumptions:

    1. The image is moved freely until the edge of QGraphicsItem meets the edge of QGraphicsView. I just dont want the Item (if it is smaller than View) to exceed the viewing area. If it is larger (wider or higher) I don't want to move it more than it needs to (i.e. if the upper edge of item exceeds the viewport, cuz its higher than viewport and the bottom edge of Item meets the bottom edge of viewport I want it to stop.) The hard thing is to get Items position at viewport. Howto get it?

    2. Zooming out Is possible until the longer edge of rectangle Item fits the viewport. Zooming in is possible until some extends (defined by me). Do i guess right it (zooming in/out) could be easily done by QTransform?

    More or less i wanna do Interface like at Google Maps instead map i wanna view finite Pixmap, and i wanna get the place at image where the user clicked mouse (thats why think QGraphicsItem is so neet in this situation).

    I guess both issues could be easily done if i would knew Items position at viewport, not at scene. Is there any possibility to determine it?

    Any other solutions that would make ui like that come to life are also welcome.

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsItem and it's position at QGraphicsView

    Why you need to know position of the item in the viewport?
    Anyway, you can use mapFromScene/mapToScene if you need.

Similar Threads

  1. Replies: 3
    Last Post: 8th February 2012, 02:57
  2. Fixed Position of QGraphicsItem
    By moh.gup@gmail.com in forum Qt Programming
    Replies: 10
    Last Post: 21st January 2012, 17:27
  3. Scale individual QGraphicsItem's size and position
    By klep in forum Qt Programming
    Replies: 1
    Last Post: 17th December 2011, 09:29
  4. Position of Items in QGraphicsScene/QGraphicsView
    By StefanK2 in forum Qt Programming
    Replies: 11
    Last Post: 7th July 2009, 15:04
  5. QGraphicsItem position
    By zgulser in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2009, 10:33

Tags for this Thread

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.