Results 1 to 1 of 1

Thread: Moving QGraphicsItems and Fitting QGraphicsView

  1. #1
    Join Date
    Jan 2010
    Location
    Istanbul, Turkey
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Moving QGraphicsItems and Fitting QGraphicsView

    Hi,

    I have some problems with QGraphicsView.fitInView method.

    I'm drawing some items on the scene and fit it to the view. That's fine. (fig0.png in the attachments)

    Then I want to move all the items to different points. Doing this, scene.itemsBoundingRect() is calculated correctly. I update the sceneRect with:

    Qt Code:
    1. self.scene().setSceneRect(self.scene().itemsBoundingRect())
    To copy to clipboard, switch view to plain text mode 

    And I call fitInView:
    Qt Code:
    1. self.fitInView(self.scene().sceneRect(), Qt.KeepAspectRatio)
    To copy to clipboard, switch view to plain text mode 

    But the view does not show the sceneRect completely but partially. (fig1.png). You can see the sceneRect drawn around the items. When I move all the items again in a different way, still the problem persists. (fig2.png)

    It seemed like QGrapihcsView could not fit when we move the items out of the boundaries. So I tried to write a minimal example. I produced 10 random ellipses, fit the view and moved them and fit them. In some cases, view could not fit the whole image. (rect.py is the example code, try running multiple times as it is random)
    Attached Images Attached Images
    Attached Files Attached Files

Similar Threads

  1. QGraphicsView and fast moving objects
    By deMarco in forum Qt Programming
    Replies: 4
    Last Post: 26th February 2009, 11:07
  2. Questions about QGraphicsItems
    By NoRulez in forum Qt Programming
    Replies: 6
    Last Post: 8th May 2008, 19:01
  3. Problems with QGraphicsItems
    By JonathanForQT4 in forum Qt Programming
    Replies: 5
    Last Post: 26th April 2007, 08:25
  4. QGraphicsView: Moving multiple selection
    By marcel in forum Qt Programming
    Replies: 1
    Last Post: 23rd April 2007, 19:59
  5. QGraphicsItems on top of each other?
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 18th November 2006, 20:23

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.