yrHeTateJlb
yrHeTateJlb

Reputation: 486

How to add labels to the QwtPlotCurve on the QwtPlot?

How to add labels to the QwtPlotCurve on the QwtPlot? enter image description here

example

Upvotes: 0

Views: 2030

Answers (1)

yrHeTateJlb
yrHeTateJlb

Reputation: 486

My solution

class QwtPlotCurveWithTitle : public QwtPlotCurve{
public:
    explicit QwtPlotCurveWithTitle( const QString &title = QString::null ) : QwtPlotCurve(title){}
    explicit QwtPlotCurveWithTitle( const QwtText &title ) : QwtPlotCurve(title){}
protected:
    virtual void drawCurve( QPainter *p, int style,
        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
        const QRectF &canvasRect, int from, int to ) const{
        QwtPlotCurve::drawCurve(p,style,xMap,yMap,canvasRect,from,to);
        QPointF point = sample(from);
        p->drawText(xMap.transform(point.x()),yMap.transform(point.y()),title().text());
    }
};

Upvotes: 1

Related Questions