Quote Originally Posted by camel View Post
Hey,

I just changed your source a bit so that the boundingrects and shapes are only calculated once...

check if that helps with the performance a bit...

(since I cannot realy judge it here... :-)



I also found that the grid-color-problem is lessend (but not gone) when you fill the rect in the draw background,

And the error is gone completely when you turn off anti-aliasing.

Might be a Qt-Bug :-/


Anyways, my version of your code :-)
Qt Code:
  1. #include <QtGui>
  2. #include <cmath>
  3.  
  4. class GridScene : public QGraphicsScene
  5. {
  6. public:
  7. ....
To copy to clipboard, switch view to plain text mode 
I am really thankful to your support.

Yeah you are right. The colouring is gone without antialiasing. But I also experimented with one more thing.
I did this in drawBackground() which didn't alter much
Qt Code:
  1. void GridScene::drawBackground(QPainter *p, const QRectF& rect) const
  2. {
  3. QPainter::RenderHints rh = p->renderHints();
  4. p->setRenderHints(0);
  5. ...
  6. p->setRenderHints(rh);
  7. }
To copy to clipboard, switch view to plain text mode 
Should be Qt bug I believe.

Calculating bounding rect beforehand did show improvement in performance. But I feel the main performance blow is in drawBackground(). Somehow I feel that drawBackground() is called more than required times which is causing all these. For example try with this
Qt Code:
  1. view->setCacheMode(QGraphicsView::CacheBackground);
To copy to clipboard, switch view to plain text mode 
The performance improves but the background corrupts when we scroll. Also as I pointed in my last but one post, increasing bounding rect of resistor so that it covers node also sigificantly improved performance. This suggests that the rects are not ORred properly before updating that region. ( I may be wrong, correct me if I am)
Well to exactly solve this we need to profile the code (with profiling enabled for qt lib) or use some intelligent techniques (which I am not aware of )