I want to set text on the rectangles of a QwtPlotHistogram. I read in a post that i need to overload drawColumn method of QwtPlotHistgram, but i cannot figure out what exactly is to be done..
I wrote
class Histogram: public QwtPlotHistogram
{
public:
void setColor
(const QColor &);
void setValues(uint numValues, const double *);
void drawColumn
(QPainter *painter,
const QwtColumnRect
&rect,
const QwtIntervalSample
&samples
);
};
class Histogram: public QwtPlotHistogram
{
public:
Histogram(const QString &, const QColor &);
void setColor(const QColor &);
void setValues(uint numValues, const double *);
void drawColumn(QPainter *painter,const QwtColumnRect &rect,const QwtIntervalSample &samples);
};
To copy to clipboard, switch view to plain text mode
and wrote this function
void Histogram
::drawColumn(QPainter *painter,
const QwtColumnRect
&rect,
const QwtIntervalSample
&sample
) {
drawColumn(painter,rect,samples);
painter->drawText(50,100,s);
}
void Histogram::drawColumn(QPainter *painter,const QwtColumnRect &rect,const QwtIntervalSample &sample)
{
drawColumn(painter,rect,samples);
QString s="My Text";
painter->drawText(50,100,s);
}
To copy to clipboard, switch view to plain text mode
I dont know what i'm missing out, because no text appeared at all with this
Bookmarks