I just got my program to display contours. (I've had it drawing them in PostScript for over a year and drawing them correctly for a few months, but just got it to draw them in Qt.) The relevant part of the paintEvent method is this:
Qt Code:
  1. for (i=0;i<doc.pl[plnum].contours.size();i++)
  2. {
  3. b3d=doc.pl[plnum].contours[i].approx3d(pixelScale());
  4. path=QPainterPath();
  5. for (k=0;k<b3d.size();k++)
  6. {
  7. beziseg=b3d[k];
  8. if (k==0)
  9. path.moveTo(worldToWindow(beziseg[0]));
  10. path.cubicTo(worldToWindow(beziseg[1]),worldToWindow(beziseg[2]),worldToWindow(beziseg[3]));
  11. }
  12. if (!doc.pl[plnum].contours[i].isopen())
  13. path.closeSubpath();
  14. contourType=doc.pl[plnum].contourInterval.contourType(doc.pl[plnum].contours[i].getElevation());
  15. painter.strokePath(path,contourPen[contourType>>8][contourType&31]);
  16. }
To copy to clipboard, switch view to plain text mode 
There are hundreds of contours, many of which have hundreds of segments (which will be spiralarcs once I smooth them), and the whole thing takes about 200 or 300 ms to draw. It's common in CAD programs to keep a list of lines to draw and regenerate the list when the scale changes by a lot, but I don't see how that can work with QPainterPaths. There's a way to translate a QPainterPath, but not to scale or rotate it. Suggestions?