PDA

View Full Version : QGraphicsView/QGraphicsScene rendering question



onurozcelik
1st July 2010, 13:44
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:


itsScene = new QGraphicsScene;
itsView = new QGraphicsView;
itsView->setParent(itsCanvas);

itsView->setGeometry(20,20,1700,720);
itsView->setBackgroundBrush(Qt::black);
itsView->setAlignment(Qt::AlignTop);
itsView->setScene(itsScene);

After adding some widgets into QGraphicsScene my application final UI snapshot is below:
http://img257.imageshack.us/img257/2360/sahagoruntu.jpg
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?

JohannesMunk
3rd July 2010, 11:23
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