API Documentation
Loading...
Searching...
No Matches
QCustomTooltip.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: QCustomTooltip
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <QString>
35#include <QPoint>
36#include <QLabel>
37#include <QBasicTimer>
38#include <QPointer>
39namespace NDEVR
40{
41 /**--------------------------------------------------------------------------------------------------
42 \brief Provides tool tips (balloon help) for any widget that usually shows up when a mouse is hovered
43 over a widget for a set amount of time.
44 *-----------------------------------------------------------------------------------------------**/
45 class NDEVR_WIDGETS_API QCustomTooltip : public QLabel
46 {
47 Q_OBJECT
48 public:
49 QCustomTooltip(const QString &text, const QPointF &pos, QWidget* parent = nullptr);
51 void updateSize(const QPointF &pos);
52 bool eventFilter(QObject *, QEvent *) override;
53 void reuseTip(const QString &text, const QPointF &pos);
54 void hideTip();
55 void hideTipImmediately(int animation_duration = -1);
56 void setTipRect(QWidget *w, const QRect &r);
57 bool tipChanged(const QPointF &pos, const QString &text, QObject *o);
58 void placeTip(const QPointF &pos, QWidget *w);
59 static QCustomTooltip* show(const QString &text, const QPointF &pos, QWidget *w, int animation_duration = -1);
60 static void hide(int animation_duration = -1);
61 static bool IsShowing();
62 int margin() const;
63 QSize sizeHint() const override;
64 void setTargetOffset(QPoint target_offset);
65 protected:
66 void timerEvent(QTimerEvent *e) override;
67 void paintEvent(QPaintEvent *e) override;
68 void mouseMoveEvent(QMouseEvent *e) override;
69 void resizeEvent(QResizeEvent *e) override;
70 public slots:
72 private:
73 QWidget *styleSheetParent;
74 int animation_duration = -1;
75 private:
76 static QPointer<QCustomTooltip> s_instance;
77 QPointer<QWidget> m_widget;
78 QRect m_rect;
79 QPoint m_target_offset;
80 QBasicTimer m_hide_timer;
81 };
82}
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:81
Provides tool tips (balloon help) for any widget that usually shows up when a mouse is hovered.
Definition QCustomTooltip.h:46
static bool IsShowing()
void styleSheetParentDestroyed()
QSize sizeHint() const override
static void hide(int animation_duration=-1)
void updateSize(const QPointF &pos)
void mouseMoveEvent(QMouseEvent *e) override
void setTargetOffset(QPoint target_offset)
bool eventFilter(QObject *, QEvent *) override
void placeTip(const QPointF &pos, QWidget *w)
void timerEvent(QTimerEvent *e) override
void reuseTip(const QString &text, const QPointF &pos)
bool tipChanged(const QPointF &pos, const QString &text, QObject *o)
static QCustomTooltip * show(const QString &text, const QPointF &pos, QWidget *w, int animation_duration=-1)
void resizeEvent(QResizeEvent *e) override
void setTipRect(QWidget *w, const QRect &r)
void paintEvent(QPaintEvent *e) override
void hideTipImmediately(int animation_duration=-1)
QCustomTooltip(const QString &text, const QPointF &pos, QWidget *parent=nullptr)
Definition ACIColor.h:37