Results 1 to 5 of 5

Thread: QGraphicsView::translate

  1. #1
    Join Date
    Oct 2008
    Posts
    37
    Thanked 2 Times in 2 Posts

    Default QGraphicsView::translate

    I don't seem to understand what QGraphicsView::translate does...was wondering if someone could help me understand it. From what I gathered by reading the documentation, it's suppose to apply the x,y to the transformation matrix. I'm lead to believe that this is suppose to move the scene + content around in the view. However, it just remains fixed at the center. I'm basing this on the QRect that is handed to me in QGraphicsScene::drawBackground. Do I need to apply a transfrom to the rect? If so - how do I get the current view's transform matrix?

    I've also tried centerOn with no sucess.

    What am I misunderstanding here?

    Thanks.

  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: QGraphicsView::translate

    Is your scene bigger than your view? If not, translating the view won't change anything.

  3. #3
    Join Date
    Oct 2008
    Posts
    37
    Thanked 2 Times in 2 Posts

    Default Re: QGraphicsView::translate

    I see what you mean by that now. How do I translate the origin of my scene in a view so that it's somewhere other than dead center?

    Also - do you know if I can turn off that auto scroll when I add items close to the edge of the view?

    Thanks.

  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: QGraphicsView::translate

    The view inherits QAbstractScrollArea. Dig out the rest yourself

    To anchor the scene to something else than the centre of the view (if it is smaller than the view) use the QGraphicsView::alignment property.

  5. #5
    Join Date
    Oct 2008
    Posts
    37
    Thanked 2 Times in 2 Posts

    Default Re: QGraphicsView::translate

    Thanks. That's a good starting point.

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.