Results 1 to 4 of 4

Thread: Graphics view coordinates - am I stupid or what?

  1. #1
    Join Date
    Mar 2009
    Posts
    13
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Graphics view coordinates - am I stupid or what?

    I posted this originally into the programming forum, but I think it belongs here...

    I'm confused with the graphics view framework coordinate system. There is so much information about all kinds of conversions, relations, mappings etc. that I haven't been able to find out solution to my trivial problem.

    The problem is: I want to draw my item so that it fills the view completely. How can I do this after I've scrolled the view? I don't want to use QGraphicsView::fitInView(), I just need to tell in my item's paint function that draw yourself and fill the whole view while doing it.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Graphics view coordinates - am I stupid or what?

    If you want an item covering the whole view, it might be better if you don't use Graphics View at all but instead implement a custom widget.

    But to answer your question - you have to be aware that the size of the view doesn't really matter. What matters is the size of the scene. What I understand you want to scroll the view and still have the item filling the view totally. You need to know the size of the viewport() of the view and you need to set your item to that size by modifying its QGraphicsItem::boundingRect(). Of course if you resize the view, you'll have to modify the bounding rect of the item too. QWidget::resizeEvent() will be helpful for that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2009
    Posts
    13
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Graphics view coordinates - am I stupid or what?

    All righty, thanks for clarifications!

    I'm using graphics view because I need to have multiple graphic items that can be handled easily. I don't know if that is the best option, but as I'm fairly new to Qt it seemed to be logical choice.

    I'm developing an image viewer software, where there are several thumbnails (QGraphicItems) spread around the graphics view. When I doubleclick a thumbnail, it's opened as "full-size" image, i.e. it fills the whole viewable area. (what is the correct term for this? viewport? I'll use that until someone proves me wrong =)

    The problem was that in some occasions when I enlarge a thumbnail, it's drawn a bit off the viewport. I want that in every occasion the top left corner of the enlarged image is in the top left corner of the viewport.

    Sorry for the longish explanation, hopefully it clarified this a bit.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Graphics view coordinates - am I stupid or what?

    Consider using QStackedWidget with a QLabel and QPixmap representing the "full" view and QGraphicsView representing the thumbnail view.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Graphics View Panning ,zooming
    By linuxdev in forum Qt Programming
    Replies: 3
    Last Post: 29th December 2008, 07:17
  2. Replies: 4
    Last Post: 5th August 2008, 19:55
  3. Graphics View Event Propagation
    By pherthyl in forum Qt Programming
    Replies: 10
    Last Post: 3rd July 2008, 10:39
  4. real world coordinates in graphics view / scene
    By robertson1 in forum Qt Programming
    Replies: 2
    Last Post: 7th December 2007, 23:21
  5. Adding Rectangular overlay on graphics view
    By forrestfsu in forum Qt Programming
    Replies: 10
    Last Post: 21st November 2006, 19:42

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.