首次提交

This commit is contained in:
2026-06-16 13:33:27 +08:00
commit 81e2f99ab5
187 changed files with 26001 additions and 0 deletions
+119
View File
@@ -0,0 +1,119 @@
#pragma once
#include "global.h"
#include <QApplication>
#include <QPropertyAnimation>
#include <QPainter>
#include <QTimer>
#include <cmath>
#include <QGraphicsDropShadowEffect>
#include "effect.h"
#include <QPainter>
#include <QPainterPath>
#include <QPainter>
#include <QPainterPath>
#include <QPainter>
#include <QPainterPath>
#include <QPainter>
#include <QPainterPath>
#include <QPainter>
#include <QPainterPath>
#include <QPainter>
#include <QPainterPath>
#include "Background.h"
struct Wave : PaintAble {
QColor color = Qt::blue;
QGraphicsDropShadowEffect shadowEffect;
Wave() {
shadowEffect.setBlurRadius(10); // 设置模糊半径
shadowEffect.setOffset(5, 5); // 设置阴影偏移量(x, y
shadowEffect.setColor(Qt::black); // 设置阴影颜色
}
void paint(QPainter* painter, QRect rect) override {
}
};
template <typename Widget>
struct Wrapper : QMainWindow {
Wrapper() {
resize(400, 400);
auto* w = new Widget();
auto* ww = static_cast<QWidget*>(w);
ww->setParent(this);
ww->setFixedSize(200, 200);
ww->move(100, 100);
}
};
class WaveWidget : public QWidget
{
Q_OBJECT
public:
explicit WaveWidget(QWidget *parent = nullptr)
: QWidget(parent), m_offset(0) {
setFixedSize(400, 300); // 设置窗口大小
// 定时器:每隔一段时间更新一次动画
m_timer = new QTimer(this);
connect(m_timer, &QTimer::timeout, this, &WaveWidget::updateWave);
m_timer->start(16); // 约60fps
// 初始化动画
m_animation = new QPropertyAnimation(this, "wavePosition");
m_animation->setDuration(1000);
m_animation->setLoopCount(-1); // 无限循环
m_animation->setEasingCurve(QEasingCurve::Linear);
}
protected:
void paintEvent(QPaintEvent *event) override {
QPainter painter(this);
painter.setBrush(Qt::blue);
// 通过 m_offset 控制波浪的 y 坐标
int y = 150 + 50 * std::sin(m_offset); // 使用正弦波函数产生波浪效果
painter.drawEllipse(QPoint(200, y), 20, 20); // 绘制一个圆形
QWidget::paintEvent(event);
}
private slots:
void updateWave() {
// 每次更新时间,更新 m_offset 以形成波动效果
m_offset += 0.1;
if (m_offset > 2 * (3.14159265358979323846)) {
m_offset = 0; // 重新从0开始
}
update(); // 更新界面
}
private:
float m_offset; // 波动的偏移量
QTimer *m_timer;
QPropertyAnimation *m_animation;
};