Results 1 to 2 of 2

Thread: QGraphicsView/QGraphicsScene rendering question

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

    Question QGraphicsView/QGraphicsScene rendering question

    I am using QGraphicsScene/QGraphicsView pair in my application. I had subclassed them for my purpose. The code snippet that generate the pair is below:

    Qt Code:
    1. itsScene = new QGraphicsScene;
    2. itsView = new QGraphicsView;
    3. itsView->setParent(itsCanvas);
    4.  
    5. itsView->setGeometry(20,20,1700,720);
    6. itsView->setBackgroundBrush(Qt::black);
    7. itsView->setAlignment(Qt::AlignTop);
    8. itsView->setScene(itsScene);
    To copy to clipboard, switch view to plain text mode 

    After adding some widgets into QGraphicsScene my application final UI snapshot is below:

    Here my question is why there is some free space above the picture? What may cause this? I am using some negative coordinates for my widgets. Is it related with that?

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView/QGraphicsScene rendering question

    Hi!

    You need to specify the exact area of the scene that the view shall visualize. Use QGraphicsView::centerOn or QGraphicsView::ensureVisible and have a look at QGraphicsView::setSceneRect.

    HIH

    Joh

Similar Threads

  1. Replies: 8
    Last Post: 7th November 2012, 19:20
  2. Rendering QGraphicsScene to QPixmap to save
    By Rooster in forum Qt Programming
    Replies: 1
    Last Post: 9th April 2009, 05:24
  3. problem in rendering opengl on QGraphicsView
    By Sandip in forum Qt Programming
    Replies: 17
    Last Post: 15th April 2008, 08:27
  4. Replies: 0
    Last Post: 7th April 2008, 14:27
  5. QGraphicsView rendering issue
    By guilugi in forum Qt Programming
    Replies: 9
    Last Post: 6th April 2007, 09:09

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.