Results 1 to 2 of 2

Thread: [QGraphicsView] Auto adjusting QGraphicsScene

  1. #1
    Join Date
    Jan 2009
    Posts
    51
    Thanks
    28
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default [QGraphicsView] Auto adjusting QGraphicsScene

    I have QGraphicsView on my form, and QGraphicsScene attached to it.
    On QGraphicsScene I have QPixmap item, and when I call pixmap->setPos(0, 0) I'd like pixmap to move exactly to left top corner of QGraphicsView.
    To reach such an effect QGraphicsScene must be expanded at whole QGraphicsView.
    In other words, QGraphicsScene's width and height must be the same as QGraphicsView's.
    How can I do it?
    I searched for function like QGraphicsScene::setAutoExpanding but I haven't found anything.

    Thanks in advance!

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: [QGraphicsView] Auto adjusting QGraphicsScene

    The scene mustn't have the same size as the view. Just use QGraphicsView::alignment and setViewportMargins() then anything should work.

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.