【问题标题】:How to add labels to the QwtPlotCurve on the QwtPlot?如何给 QwtPlot 上的 QwtPlotCurve 添加标签?
【发布时间】:2015-05-07 07:24:46
【问题描述】:

如何在 QwtPlot 上给 QwtPlotCurve 添加标签?

例子

【问题讨论】:

  • 也许使用QwtPlotItem::setTitle()函数?
  • 是QwtLegend用的吧?

标签: c++ qt qwt


【解决方案1】:

我的解决方案

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());
    }
};

【讨论】:

    猜你喜欢
    • 2018-09-11
    • 2015-10-17
    • 2021-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多