DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
darrowbutton.h
浏览该文件的文档.
1// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DARROWBUTTON_H
6#define DARROWBUTTON_H
7
8#include <QWidget>
9#include <QLabel>
10#include <QStyle>
11
12#include <dtkwidget_global.h>
13#include <dconstants.h>
14
15DWIDGET_BEGIN_NAMESPACE
16
17class ArrowButtonIcon : public QLabel
18{
19 Q_OBJECT
20 Q_PROPERTY(int arrowButtonDirection READ arrowDirection)
21 Q_PROPERTY(int arrowButtonState READ buttonState)
22public:
23 explicit ArrowButtonIcon(QWidget *parent = 0);
24 void setArrowDirection(int direction);
25 void setButtonState(int state);
26 int arrowDirection() const;
27 int buttonState() const;
28
29private:
30 int m_direction;
31 int m_buttonState;
32};
33
34class LIBDTKWIDGETSHARED_EXPORT DArrowButton : public QLabel
35{
36 Q_OBJECT
37public:
44
50
51 explicit DArrowButton(QWidget *parent = 0);
52 void setArrowDirection(ArrowDirection direction);
53 int arrowDirection() const;
54 int buttonState() const;
55
56protected:
57 void mousePressEvent(QMouseEvent *event);
58 void mouseReleaseEvent(QMouseEvent *event);
59 void enterEvent(QEvent *);
60 void leaveEvent(QEvent *);
61
62Q_SIGNALS:
63 void mousePress();
64 void mouseRelease();
65 void mouseEnter();
66 void mouseLeave();
67
68private:
69 void initButtonState();
70 void setButtonState(ArrowButtonState state);
71 void updateIconDirection(ArrowDirection direction);
72 void updateIconState(ArrowButtonState state);
73
74private:
75 ArrowButtonIcon *m_normalLabel = NULL;
76 ArrowButtonIcon *m_hoverLabel = NULL;
77 ArrowButtonIcon *m_pressLabel = NULL;
78
79 ArrowDirection m_arrowDirection = ArrowDown;
80 ArrowButtonState m_buttonState = ArrowStateNormal;
81};
82
83DWIDGET_END_NAMESPACE
84
85#endif // DARROWBUTTON_H
Definition darrowbutton.h:18
可以使用 DArrowButton 类快速创建箭头形状的按钮。
Definition darrowbutton.h:35
ArrowButtonState
表示箭头图标的方向
Definition darrowbutton.h:45
@ ArrowStateHover
鼠标在按钮上方悬停状态
Definition darrowbutton.h:47
@ ArrowStateNormal
普通状态
Definition darrowbutton.h:46
ArrowDirection
表示箭头图标的方向
Definition darrowbutton.h:38
@ ArrowLeft
箭头朝左
Definition darrowbutton.h:41
@ ArrowDown
箭头朝下
Definition darrowbutton.h:40
@ ArrowUp
箭头朝上
Definition darrowbutton.h:39