Browse Source

V0.8.11
1、添加了一种新的阴影创建方法

Apple 2 weeks ago
parent
commit
bedfa527c5
2 changed files with 45 additions and 0 deletions
  1. 20 0
      common/Shadow/OneShadowEffect.cpp
  2. 25 0
      common/Shadow/OneShadowEffect.h

+ 20 - 0
common/Shadow/OneShadowEffect.cpp

@@ -0,0 +1,20 @@
+#include "OneShadowEffect.h"
+
+
+OneShadowEffect::OneShadowEffect(QObject *parent, int radius)
+    : QGraphicsDropShadowEffect(parent)
+{
+    init(radius);
+}
+
+OneShadowEffect::~OneShadowEffect()
+{
+
+}
+
+void OneShadowEffect::init(int radius)
+{
+    setBlurRadius(radius);              // 模糊半径
+    setColor(QColor(0, 0, 0, 90));      // 阴影的颜色
+    setOffset(0, 0);                    // 水平和垂直偏移量
+}

+ 25 - 0
common/Shadow/OneShadowEffect.h

@@ -0,0 +1,25 @@
+#ifndef ONESHADOWEFFECT_H
+#define ONESHADOWEFFECT_H
+
+#include <QGraphicsDropShadowEffect>
+
+/**
+ * @brief 使用方式:
+            1、创建实例,设置阴影半径,如:OneShadowEffect *shadow = new OneShadowEffect(this, 20);
+            2、给需要添加阴影的控件设置setGraphicsEffect(show);
+ */
+
+
+class OneShadowEffect : public QGraphicsDropShadowEffect
+{
+
+public:
+    OneShadowEffect(QObject *parent = nullptr, int radius = 20);
+    ~OneShadowEffect();
+
+private:
+    void init(int radius);
+
+};
+
+#endif // ONESHADOWEFFECT_H