Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, July 2007
Performance issue with QGraphicsView Framework


Message 1 in thread

Hi,
 
I am seeing a major performance hit using the QGraphicsFramework.
Below is a code that showcases the problem.
I have created 200 items. Once I select all of them and move around the
canvas, response is very slow.
Is there anything that I am doing wrong or is there a different approach
to do this ?
 
int main(int argc, char** argv)
{
    QApplication app(argc,argv);
    QGraphicsScene *scene = new QGraphicsScene();
    scene->setSceneRect(QRectF(0,0,2500,2500));
    QGraphicsView m_view(scene);
    m_view.setDragMode(QGraphicsView::RubberBandDrag);
    m_view.show();
for(int i = 0 ; i < 200 ; i++)
{
    QGraphicsRectItem *item = new QGraphicsRectItem(QRectF(-50, -50,
100,100), NULL, scene);
    item->setFlag(QGraphicsItem::ItemIsMovable);
    item->setFlag(QGraphicsItem::ItemIsSelectable);
    item->setPos(i+100 + 10 * i, i+100 + 10 * i);
}
 
return app.exec();
}
 
Regards
Prateek