CustomHistogramBars.h 875 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef CUSTOMHISTOGRAMBARS_H
  2. #define CUSTOMHISTOGRAMBARS_H
  3. #include "qcustomplot.h"
  4. /**
  5. * @brief 柱状图上显示值
  6. */
  7. class CustomHistogramBars : public QCPBars
  8. {
  9. Q_OBJECT
  10. public:
  11. explicit CustomHistogramBars(QCPAxis *keyAxis, QCPAxis *valueAxis);
  12. Qt::Alignment textAligment() const { return m_textAlignment; }
  13. double spacing() const { return m_spacing; }
  14. QFont font() const { return m_font; }
  15. void setTextAlignment(Qt::Alignment alignment);
  16. void setSpacing(double spacing);
  17. void setFont(const QFont &font);
  18. protected:
  19. Qt::Alignment m_textAlignment; // 文字对齐方式
  20. double m_spacing; // 文字与柱状图的间距,这里按像素大小
  21. QFont m_font; // 文字使用的字体
  22. virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE;
  23. };
  24. #endif // CUSTOMHISTOGRAMBARS_H