Hi,

I need to draw 12,000 arrows pointing to different directions depending on data. It take very long time (about 1.5 seconds) to finish.

Following is the codes. If I comment out painter->drawPolyon(...), it only takes 0.037 seconds. Is there a way to speed it up? Thanks!

Qt Code:
  1. QRectF Rect( QPointF( 0, 0 ), QSizeF( 3, 3 ) );
  2. Rect.moveCenter( QPointF( 0, 0 ) );
  3.  
  4. QPolygonF arrow( 3 );
  5. arrow[ 0 ] = Rect.topLeft();
  6. arrow[ 1 ] = QPointF( Rect.right(), 0 );
  7. arrow[ 2 ] = Rect.bottomLeft();
  8.  
  9. painter->setBrush( Qt::black ); // fill with black on the arrow head
  10.  
  11. for ( int idx = 0; idx < dataSize; idx++ ) { // dataSize = 12,000
  12.  
  13. painter->save();
  14.  
  15. painter->translate( ... ) // translate to arrow location
  16. painter->rotate( ... ) // rotate to angle degree depending on data
  17.  
  18. QLineF line( QPointF( 0, 0 ), QPointF( length, 0 ) ); // length is calculated from data
  19. painter->drawLine( line );
  20. painter->drawPolyon( arrow.translated( length, 0 ) );
  21.  
  22. painter->restore();
  23. }
To copy to clipboard, switch view to plain text mode