Hi,

I needed to inherit from qwt_plot_curve to add another CurveStyle (DottedLines) to the enum:

Qt Code:
  1. /*
  2.   - UserCurve
  3.   Styles >= UserCurve are reserved for derived
  4.   classes of QwtPlotCurve that overload drawCurve() with
  5.   additional application specific curve types.
  6. */
  7. enum CurveStyle
  8. {
  9. NoCurve,
  10.  
  11. Lines,
  12. Sticks,
  13. Steps,
  14. Dots,
  15.  
  16. UserCurve = 100
  17. };
To copy to clipboard, switch view to plain text mode 

I wanted to make a style called DottedLine, which connects every other point with a line. I need to derive a class and then redefine DrawCurve:

Qt Code:
  1. void QwtPlotCurve::drawCurve(QPainter *painter, int style,
  2. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  3. int from, int to) const
  4. {
  5. switch (style)
  6. {
  7. case Lines:
  8. if ( testCurveAttribute(Fitted) )
  9. {
  10. // we always need the complete
  11. // curve for fitting
  12. from = 0;
  13. to = dataSize() - 1;
  14. }
  15. drawLines(painter, xMap, yMap, from, to);
  16. break;
  17. case Sticks:
  18. drawSticks(painter, xMap, yMap, from, to);
  19. break;
  20. case Steps:
  21. drawSteps(painter, xMap, yMap, from, to);
  22. break;
  23. case Dots:
  24. drawDots(painter, xMap, yMap, from, to);
  25. break;
  26. case DottedLines:
  27. drawDottedLines(painter, xMap, yMap, from, to);
  28. break;
  29. case NoCurve:
  30. default:
  31. break;
  32. }
  33. }
To copy to clipboard, switch view to plain text mode 

(I added drawDottedLines at the bottom). How can I inherit the enum CurveStyles such that I can set the style using:

void QwtPlotCurve::setStyle(CurveStyle style)?

I can't inherit the enum right? Do I need to redefine setStyle to:

void MyPlotCurve::setStyle(MyCurveStyle style)? And if so, how do I define MyCurveStyle?

I hope this is not too confusing, thanks