头文件
#include "qtheader_file.h"
class DistroChartItem;
typedef struct BarData
{
QString distro;
int hits;
QColor color;
}BAR_DATA;
class CBartlePlot : public QwtPlot
{
Q_OBJECT
public:
CBartlePlot(QWidget *parent,int nsize,QVector<double> &vtvalue,QVector<QString> &vtname);
~CBartlePlot();
private:
void CBartlePlot::setOrientation( int o );
DistroChartItem *d_barChartItem;//自定义直方图类
QStringList d_distros;//改变方向重置标题用
BAR_DATA *m_data;
};
#include "cbartleplot.h"
******************************/
class DistroScaleDraw: public QwtScaleDraw
{
public:
DistroScaleDraw( Qt::Orientation orientation, const QStringList &labels ):
d_labels( labels )
{
//设置坐标轴刻度线的长度
setTickLength( QwtScaleDiv::MinorTick, 0 );
setTickLength( QwtScaleDiv::MediumTick, 0 );
setTickLength( QwtScaleDiv::MajorTick, 10 );
//不显示刻度线坐落的部件
enableComponent( QwtScaleDraw::Backbone, false );
//标签显示的样式
setLabelAlignment( Qt::AlignLeft | Qt::AlignVCenter);
}
//刻度标签值
virtual QwtText label( double value) const
{
QwtText lbl;
const int index = qRound( value );//四舍五入
if ( index >= 0 && index < d_labels.size() )
{
lbl = d_labels[ index ];
}
return lbl;
}