Results 1 to 6 of 6

Thread: Scrolling QGraphicsView and QGraphicsScene

  1. #1
    Join Date
    Jul 2010
    Posts
    72
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Scrolling QGraphicsView and QGraphicsScene

    Hi,

    I have QGraphicsScene instance set to QGraphicsView on the GUI with scrollbars enabled and full view port update. But when I scroll my graphics view I get the items added to qgraphics scene disappeared on some point,

    though they are added in code correctly and are expected to be displayed upon scroll ( custom class inherited from QGraphicsItem ):


    Qt Code:
    1. class CSquare : public QObject, public QGraphicsItem
    To copy to clipboard, switch view to plain text mode 


    One can see how they disappear on application run on this video screen cast:

    https://www.box.com/s/h4h94×1avgay1crzvyzx

    Can somebody hint what is the problem, how to resolve so the graphics items will not disappear on the view?

    Thanks in advance.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Scrolling QGraphicsView and QGraphicsScene

    As the link does not work, and with not much information I can only guess that you might have some problem with bounding rectangle
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Scrolling QGraphicsView and QGraphicsScene

    Why do you not derive your object from QGraphicsObject? It is essentially the same as you are doing manually now, and does it correctly.

    But as Santosh says, without code we have no clue what you might be doing wrong.

  4. #4
    Join Date
    Jul 2010
    Posts
    72
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Scrolling QGraphicsView and QGraphicsScene

    sorry for that incorrect link:
    try this link for the video:
    https://www.box.com/s/h4h94x1avgay1crzvyzx

  5. #5
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Scrolling QGraphicsView and QGraphicsScene

    My player does not support .ogv files yet

    So show us how do you implement CSquare class?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  6. #6
    Join Date
    Jul 2010
    Posts
    72
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Scrolling QGraphicsView and QGraphicsScene

    Thank you. Santosh is absolutely right - the problem was in custom function in the inherited class:

    Qt Code:
    1. QRectF boundingRect() const;
    To copy to clipboard, switch view to plain text mode 

    That should return valid rectangle. Now I fixed that in my project and m going to remove the video.

    Thank you very much.

    http://realvirtualdevelopment.co.nr.

Similar Threads

  1. QGraphicsView and Scrolling
    By validator in forum Qt Programming
    Replies: 5
    Last Post: 8th September 2017, 00:27
  2. QGraphicsScene and View scrolling problem
    By ithinkso in forum Newbie
    Replies: 2
    Last Post: 2nd June 2011, 11:35
  3. Replies: 1
    Last Post: 15th March 2010, 08:51
  4. QGraphicsView scrolling problem with 4.3.0
    By hb in forum Qt Programming
    Replies: 8
    Last Post: 30th August 2007, 22:18
  5. Replies: 4
    Last Post: 25th April 2007, 16:54

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.