Results 1 to 4 of 4

Thread: [QGraphicsView] centerOn() with smooth scrolling

  1. #1
    Join Date
    Apr 2010
    Posts
    9
    Thanks
    1

    Default [QGraphicsView] centerOn() with smooth scrolling

    Is there any way to get something similar to the function centerOn() but with smooth scrolling?
    I have the scene (-640, -780, 1280, 1560) and one item (football player) that is following the cursor all the time.
    I want the view to display this item just as centerOn() but without jumps when scrolling. It's because centerOn() uses int instead of qreal. I have tried many things, for example: setSceneRect( sceneRect().translated( diff.x, diff.y ) ) where diff is difference between item position and mapToScene( geometry().center() ) but it doesn't work as expected.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: [QGraphicsView] centerOn() with smooth scrolling

    Quote Originally Posted by And_re View Post
    It's because centerOn() uses int instead of qreal.
    Not according to the documentation:
    http://doc.qt.nokia.com/4.6/qgraphicsview.html#centerOn

  3. #3
    Join Date
    Apr 2010
    Posts
    9
    Thanks
    1

    Default Re: [QGraphicsView] centerOn() with smooth scrolling

    But I talk about implementation of this function in sources.
    And there is something like that:
    horizontalScrollBar()->setValue(int(viewPoint.x() - width / 2.0));
    verticalScrollBar()->setValue(int(viewPoint.y() - height / 2.0));

  4. #4
    Join Date
    Oct 2009
    Posts
    151
    Thanks
    6
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [QGraphicsView] centerOn() with smooth scrolling

    use translate() rather than centreOn().
    Got to keep the loonies on the path ...

Similar Threads

  1. Smooth Text Scrolling
    By Jones in forum Newbie
    Replies: 11
    Last Post: 19th November 2011, 19:40
  2. "Smooth" Scrolling, QGraphicsView
    By nearlyNERD in forum Qt Programming
    Replies: 5
    Last Post: 25th February 2010, 18:18
  3. QGraphicsView::centerOn not working propery in 4.6
    By deca5423 in forum Qt Programming
    Replies: 4
    Last Post: 28th January 2010, 01:16
  4. Smooth lines in QGraphicsView
    By JaRo999 in forum Qt Programming
    Replies: 4
    Last Post: 27th September 2009, 16:38
  5. Smooth pixmap transform in QGraphicsView problem
    By spud in forum Qt Programming
    Replies: 1
    Last Post: 24th October 2007, 17:47

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.