PDA

View Full Version : creating custom curve style



kja
16th March 2011, 03:00
Hi I am having a problem making my own QwtPlotCurve style. I want to make dotted lines like this post http://www.qtcentre.org/threads/20173-Custom-CurveStyle-for-qwt_plot_curve?highlight=dottedlines but I can't figure out how to call my new curve style.

My question is how do I actually call my style?

right now I put the built in curve styles into a list of styles like this


QwtPlotCurve::CurveStyle Styles[] = { QwtPlotCurve::Lines, QwtPlotCurve::Sticks, QwtPlotCurve::Steps, QwtPlotCurve::Dots};
for( int i = 0; i < 4; i++)
this->Styles[i] = Styles[i];

am I supposed to add QwtPlotCurve::UserCurve into that list, and if so how do I make sure it calls my reimplemented drawCurve? I think I am missing something basic.

Another idea that I had was to just call my class when I try to set the style


curve->setStyle(dotLines->DottedLines);

but I get the error 'QwtPlotCurve::setStyle' : cannot convert parameter 1 from 'DotLines::curveStyle' to 'QwtPlotCurve::CurveStyle'

which confuses me because my class DotLines inherits from QwtPlotCurve



class DotLines : public QwtPlotCurve{
public:

enum curveStyle
{
DottedLines = QwtPlotCurve::UserCurve + 1000
};


virtual void drawCurve( QPainter * painter, int style, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const{
if( style < QwtPlotCurve ::UserCurve )
QwtPlotCurve::drawCurve(painter, style, xMap, yMap, canvasRect, from, to );
}else{
/// make dotted lines
}

};



Any Ideas? Thanks

Uwe
16th March 2011, 06:53
Well. this is more a C++ beginner question, than Qwt related. The simple answer is: use casts.

Uwe