saifulkhan
28th March 2013, 00:03
Dear All,
I am using qt 5.0.1 in windows. I am creating 200k+ custom QGraphicsItem. I have added basic functionalists in these custom items, like mouse hover, mouse click etc.. This items are static. But on top of these items I add some items (200 max) which animates (different property animation, scale, opacity etc).
When I add those items in the scene it become extremely slow, in a relatively powerful workstation.
QGraphicsScene *scene = new QGraphicsScene();
scene->setSceneRect(0, 0, width, height);
scene->setBackgroundBrush(Qt::darkGray);
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
QGraphicsView *view = new QGraphicsView( scene );
view->setRenderHint(QPainter::Antialiasing, false);
view->setResizeAnchor(QGraphicsView::AnchorViewCenter);
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff) ;
view->resize( width, height );
view->setOptimizationFlags(QGraphicsView::DontSavePainte rState);
view->setViewportUpdateMode( QGraphicsView::SmartViewportUpdate);
view->setTransformationAnchor(QGraphicsView::AnchorUnder Mouse);
view->setCacheMode(QGraphicsView::CacheBackground);
view->setViewportUpdateMode( QGraphicsView::FullViewportUpdate);
view->show();
I have tried the following, but it makes the rendered view extremely bad, as it seems to enable antialiasing, but I need some pixel label precision.
view->setViewport(new QGLWidget( QGLFormat()));
Am I missing some important Qt programming tricks? Please suggest. I can post the code, or explain more if in case please let me know. Thanks in advance.
I am using qt 5.0.1 in windows. I am creating 200k+ custom QGraphicsItem. I have added basic functionalists in these custom items, like mouse hover, mouse click etc.. This items are static. But on top of these items I add some items (200 max) which animates (different property animation, scale, opacity etc).
When I add those items in the scene it become extremely slow, in a relatively powerful workstation.
QGraphicsScene *scene = new QGraphicsScene();
scene->setSceneRect(0, 0, width, height);
scene->setBackgroundBrush(Qt::darkGray);
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
QGraphicsView *view = new QGraphicsView( scene );
view->setRenderHint(QPainter::Antialiasing, false);
view->setResizeAnchor(QGraphicsView::AnchorViewCenter);
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff) ;
view->resize( width, height );
view->setOptimizationFlags(QGraphicsView::DontSavePainte rState);
view->setViewportUpdateMode( QGraphicsView::SmartViewportUpdate);
view->setTransformationAnchor(QGraphicsView::AnchorUnder Mouse);
view->setCacheMode(QGraphicsView::CacheBackground);
view->setViewportUpdateMode( QGraphicsView::FullViewportUpdate);
view->show();
I have tried the following, but it makes the rendered view extremely bad, as it seems to enable antialiasing, but I need some pixel label precision.
view->setViewport(new QGLWidget( QGLFormat()));
Am I missing some important Qt programming tricks? Please suggest. I can post the code, or explain more if in case please let me know. Thanks in advance.