Hi

I like QGraphicsView very much, but I vave some issue with performance. I used to search help on forums histroy but I still need some help.

On my scene I have a video some CLVideoWindow’s items ihereted from QGraphicsItem. Basicly each CLVideoWindow object dispaying live video ( video size is about 800x60, so boundingRect returns QRectF(0,0,800,600).

void CLVideoWindow:aint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) function does some OpenGL shaders.

So, as you can see my items is preaty dynamic. I need to call item->update() function in gui thread ~20-30 times per second for each item.

And it works fine with 2 itimes, but as soon as I add third item on the scene gui thread cpu usage jumps form 6-8% up to 30-36%. Threre is no differences beween 1 2 and 3 items ( they just display different video content ).

Problem is not in CLVideoWindow:aint function. Even if I do not do anything inside paint(…) ( just return ) gui thread takes almost the same CPU time. If I do not call update() so ofen – it’s fine ( low cpu usage ).

The problem apears only if I add third item(no metter in what sequence). I also noticed that if I maximize application gui thread also takes more CPU ( but not always ).

After I add 4,5,6.. items cpu increased on 4-5% ( this is expactable ). But how come third item gives such dramatic increase?

I have QT.4.5.2 Windows Xp / Vista.


Here are options I use for my QGraphicsView( I do not use Antialiasing):

Qt Code:
  1. m_View.setViewport(new QGLWidget());
  2.  
  3. m_View.setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
  4.  
  5. m_View.setCacheMode(QGraphicsView::CacheBackground);
  6.  
  7.  
  8. m_View.setDragMode(QGraphicsView::ScrollHandDrag);
  9.  
  10. m_View.setOptimizationFlag(QGraphicsView::DontClipPainter);
  11. m_View.setOptimizationFlag(QGraphicsView::DontSavePainterState);
  12. m_View.setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing);
  13.  
  14. m_View.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  15. m_View.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
To copy to clipboard, switch view to plain text mode 



Thank you in advance.