oneshadow.h 788 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef ONESHADOW_H
  2. #define ONESHADOW_H
  3. #include <QSize>
  4. #include <QColor>
  5. #include <QImage>
  6. /**
  7. * OneShadow的用法,把这个类放到需要显示阴影的控件下面
  8. * 也就是他的父类上,在父类的paintEvent()函数里绘制image
  9. *
  10. * QPainter painter(this);
  11. * painter.setRenderHint(QPainter::Antialiasing);
  12. * painter.drawImage(QPoint(0,0),m_shadow->image());
  13. */
  14. class OneShadow
  15. {
  16. public:
  17. OneShadow(QSize contentSize,int radius = 5,QColor shadowColor = QColor(0, 0, 0, 60));
  18. ~OneShadow();
  19. QImage& image();
  20. private:
  21. // int radius; /* 阴影的宽度 */
  22. // QSize contentSize; /* 阴影上面内容的大小 */
  23. // QColor shadowColor; /* 颜色 */
  24. QImage* m_image = nullptr;
  25. };
  26. #endif // ONESHADOW_H