-
Notifications
You must be signed in to change notification settings - Fork 364
/
mainwindow.h
71 lines (61 loc) · 1.49 KB
/
mainwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QPainterPath>
#include <QMouseEvent>
#include <QHoverEvent>
#include <QPainter>
#include <QImage>
#include <QPropertyAnimation>
#include <QTimer>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
Q_PROPERTY(double curIndex READ getCurIndex WRITE setCurIndex NOTIFY curIndexChanged)
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
double getCurIndex() const;
void setCurIndex(double index);
protected:
bool event(QEvent *e) override;
void paintEvent(QPaintEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
private:
//计算图片位置
void calcImagePos();
//计算按钮位置
void calcBtnPath();
//切换到下一个图
void toPrev();
//切换到上一个图
void toNext();
signals:
void curIndexChanged();
private:
Ui::MainWindow *ui;
struct ImageNode{
QImage img;
double xf{0};
double yf{0};
double zf{0};
};
//当前图片列表
QVector<ImageNode> imageList;
//按钮位置
QVector<QRectF> btnList;
//图片z堆叠顺序
QVector<int> drawList;
//当前设置的index
int setIndex{0};
//属性动画绘制用到的index
double curIndex{0.0};
//旋转动画
QPropertyAnimation animation;
//自动切换定时器
QTimer swipTimer;
};
#endif // MAINWINDOW_H