Results 1 to 2 of 2

Thread: fit QGraphicscene to QGraphicsview

  1. #1
    Join Date
    Oct 2009
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default fit QGraphicscene to QGraphicsview

    Hi,

    I have a QGraphicsview object which have a QGraphicscene.
    I implemented it this way:
    m_view = new QGraphicsView(m_scene,this);
    (m_scene is a QGraphicsScene).
    How can i display the scene , that it will fit the view?


    Thanks

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

    Default Re: fit QGraphicscene to QGraphicsview

    I'm also a newbie but I just used the following code. It might be useless or redundant but you might give it a try:

    Qt Code:
    1. self.mainView.setSceneRect(self.mainScene.sceneRect())
    2. self.mainView.fitInView(self.mainScene.sceneRect(),Qt.KeepAspectRatio)
    To copy to clipboard, switch view to plain text mode 

    C++ conversion (I hope it's correct):
    Qt Code:
    1. m_view = new QGraphicsView(m_scene,this);
    2. m_view->setSceneRect(m_scene->sceneRect());
    3. m_view->fitInView(m_scene->sceneRect(), Qt::KeepAspectRatio);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Qgraphicscene - rendering
    By jsmith in forum Qt Programming
    Replies: 0
    Last Post: 22nd July 2009, 13:08
  2. QGraphicScene to stream
    By phannent in forum Newbie
    Replies: 2
    Last Post: 28th June 2008, 09:43
  3. QGraphicScene and different topmost QGraphicItem
    By Xaar in forum Qt Programming
    Replies: 3
    Last Post: 5th December 2007, 16:58
  4. QGraphicScene MousePressEvent
    By Spitz in forum Qt Programming
    Replies: 3
    Last Post: 16th November 2007, 21:46
  5. Custom objects in a QGraphicScene
    By draand in forum Qt Programming
    Replies: 2
    Last Post: 24th July 2007, 11:31

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.