PDA

View Full Version : QGraphicsView::fitInView()



stella1016
30th March 2011, 13:52
Anybody knows the implied difference between these pieces of code? Any duplicated updating?
Thanks.


void my_graphicsView::resizeEvent(QResizeEvent *event)
{
setWidth(event->size().width());
setHeight(event->size().height());

fitInView(QRectF(0,0,width(),height()),Qt::KeepAsp ectRatioByExpanding);
arrangeNodes();

m_scene->setSceneRect(0,0,width(),height());
this->setSceneRect(0,0,width(),height());

update();
}


void my_graphicsView::resizeEvent(QResizeEvent *event)
{
setWidth(event->size().width());
setHeight(event->size().height());

fitInView(QRectF(0,0,width(),height()),Qt::KeepAsp ectRatioByExpanding);
arrangeNodes();

m_scene->update(0,0,width(),height());
update();
}

high_flyer
30th March 2011, 14:28
Is this home work?

stella1016
30th March 2011, 16:25
Is this home work?

fitInView() works.

But it I comment it out, the paiting quality seems to be lower.

In QGraphicsItem's paint(), I have:



painter->setRenderHint(QPainter::SmoothPixmapTransform);
painter->setPen(QPen(Qt::red));
painter->setBrush(QBrush(Qt::gray, Qt::Dense4Pattern));


Actually there is another post which is related to my problem:
http://www.qtcentre.org/threads/40130-QGraphicsRectItem-in-FullScreen-mode-when-mouse-dragging-blinking

high_flyer
30th March 2011, 18:49
fitInView() works.

But it I comment it out, the paiting quality seems to be lower.
Well it might for example, if the fitInView() has to cause scaling up for the drawn elements.