Results 1 to 6 of 6

Thread: Scrolling problem with background using View/Scene

  1. #1
    Join Date
    Sep 2007
    Location
    Pune, India
    Posts
    60
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Scrolling problem with background using View/Scene

    Hi,
    I am using view/Scene architecture to show rectangels and lines with background picture.
    I have drawn background in GraphicsScene::drawBackground(..) function.
    To speed up rendering I have set cache background
    Qt Code:
    1. view->setCacheMode(QGraphicsView::CacheBackground);
    To copy to clipboard, switch view to plain text mode 
    But using this when I zoom and then scroll the content there is artifacts comes. After scrolling scene doesnt refresh property.Background image doesnt refresh.

    I have tried using
    Qt Code:
    1. GraphicsView::scrollContentsBy(int dx, int dy)
    2. {
    3. scene()->invalidate(sceneRect(), QGraphicsScene::BackgroundLayer);
    4. QGraphicsView::scrollContentsBy(dx, dy);
    5. }
    To copy to clipboard, switch view to plain text mode 
    But this also doesnt refersh the screen.
    I want to refresh only portion which is visible because of scrolling.
    Can anybody have solution for this.
    Last edited by wysota; 22nd October 2007 at 06:12. Reason: missing [code] tags

  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: Scrolling problem with background using View/Scene

    How did you implement drawBackground()? What happens if you disable the cache?

  3. #3
    Join Date
    Sep 2007
    Location
    Pune, India
    Posts
    60
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Scrolling problem with background using View/Scene

    I have drawn background using svg render class.
    If I disable the cache, and select the rectangle & move them, it becomes very slow.
    So i m tring to use cache background. But with cache background it doesnt refershe the screen after zooming and then scrolling.
    I want to refersh the portion of screen which is visible due to scrolling after zooming the screen.

  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: Scrolling problem with background using View/Scene

    So without caching the background the output is correct? From what I understand the caching will cause a degrade in quality while zooming, because it converts the vector-based svg to a bitmap based pixmap. But I don't know if that's the effect you are experiencing.

  5. #5
    Join Date
    Sep 2007
    Location
    Pune, India
    Posts
    60
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Scrolling problem with background using View/Scene

    Without cache background output is correct but it slows down rendering,Also if we select rects and move them it also slows down.
    Can you tell me which is faster svg rendering Or bitmap ?
    Last edited by nileshsince1980; 22nd October 2007 at 06:59.

  6. #6
    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: Scrolling problem with background using View/Scene

    bitmap is definitely faster. I suggest you do your own caching - render the svg to a pixmap after each zoom using the needed pixmap size and then just draw the pixmap from within drawBackground(). Just make sure you invalidate and rerender the pixmap after each change to the zoom level. An alternative is to get rid of svg and just render to pixmap once and then use it as a background brush for your scene.

Similar Threads

  1. QTreeView problem scrolling to end.
    By seneca in forum Qt Programming
    Replies: 7
    Last Post: 22nd December 2015, 12:08
  2. QGraphicsView scrolling problem with 4.3.0
    By hb in forum Qt Programming
    Replies: 8
    Last Post: 30th August 2007, 22:18
  3. Replies: 2
    Last Post: 8th October 2006, 20:14

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.