penny
6th January 2011, 04:45
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:
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);
};
and wrote this function
void Histogram::drawColumn(QPainter *painter,const QwtColumnRect &rect,const QwtIntervalSample &sample)
{
drawColumn(painter,rect,samples);
QString s="My Text";
painter->drawText(50,100,s);
}
I dont know what i'm missing out, because no text appeared at all with this
I wrote
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);
};
and wrote this function
void Histogram::drawColumn(QPainter *painter,const QwtColumnRect &rect,const QwtIntervalSample &sample)
{
drawColumn(painter,rect,samples);
QString s="My Text";
painter->drawText(50,100,s);
}
I dont know what i'm missing out, because no text appeared at all with this