QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgsfloatingwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsfloatingwidget.h
3 -------------------
4 begin : April 2016
5 copyright : (C) Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#ifndef QGSFLOATINGWIDGET_H
16#define QGSFLOATINGWIDGET_H
17
18#include <QWidget>
19#include <QPointer>
20#include "qgis_sip.h"
21#include "qgis_gui.h"
22
23class QgsFloatingWidgetEventFilter;
24
33class GUI_EXPORT QgsFloatingWidget : public QWidget
34{
35 Q_OBJECT
36 Q_PROPERTY( QWidget *anchorWidget READ anchorWidget WRITE setAnchorWidget NOTIFY anchorWidgetChanged )
37 Q_PROPERTY( AnchorPoint anchorPoint READ anchorPoint WRITE setAnchorPoint NOTIFY anchorPointChanged )
38 Q_PROPERTY( AnchorPoint anchorWidgetPoint READ anchorWidgetPoint WRITE setAnchorWidgetPoint NOTIFY anchorWidgetPointChanged )
39
40 public:
54 Q_ENUM( AnchorPoint )
55
56
60 QgsFloatingWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
61
68 void setAnchorWidget( QWidget *widget );
69
75 QWidget *anchorWidget();
76
82 AnchorPoint anchorPoint() const { return mFloatAnchorPoint; }
83
90 void setAnchorPoint( AnchorPoint point );
91
98 AnchorPoint anchorWidgetPoint() const { return mAnchorWidgetAnchorPoint; }
99
106 void setAnchorWidgetPoint( AnchorPoint point );
107
108 signals:
109
111 void anchorWidgetChanged( QWidget *widget );
112
115
118
119 protected:
120 void showEvent( QShowEvent *e ) override;
121 void paintEvent( QPaintEvent *e ) override;
122 void resizeEvent( QResizeEvent *e ) override;
123
124 private slots:
125
127 void onAnchorPointChanged();
128
129 private:
130 QPointer<QWidget> mAnchorWidget;
131 QgsFloatingWidgetEventFilter *mParentEventFilter = nullptr;
132 QgsFloatingWidgetEventFilter *mAnchorEventFilter = nullptr;
133 AnchorPoint mFloatAnchorPoint = BottomMiddle;
134 AnchorPoint mAnchorWidgetAnchorPoint = TopMiddle;
135};
136
137
138#ifndef SIP_RUN
139
141
142class QgsFloatingWidgetEventFilter : public QObject
143{
144 Q_OBJECT
145
146 public:
147 QgsFloatingWidgetEventFilter( QWidget *parent = nullptr );
148
149 bool eventFilter( QObject *object, QEvent *event ) override;
150
151 signals:
152
154 void anchorPointChanged();
155};
156
158
159#endif
160
161#endif // QGSFLOATINGWIDGET_H
A QWidget subclass for creating widgets which float outside of the normal Qt layout system.
void anchorWidgetPointChanged(QgsFloatingWidget::AnchorPoint point)
Emitted when the anchor widget point changes.
void anchorPointChanged(QgsFloatingWidget::AnchorPoint point)
Emitted when the anchor point changes.
AnchorPoint anchorWidgetPoint() const
Returns the anchor widget's anchor point, which corresponds to the point on the anchor widget which t...
AnchorPoint
Reference points for anchoring widget position.
@ BottomMiddle
Bottom center of widget.
@ TopMiddle
Top center of widget.
@ MiddleRight
Middle right of widget.
@ MiddleLeft
Middle left of widget.
@ BottomRight
Bottom-right of widget.
@ BottomLeft
Bottom-left of widget.
@ Middle
Middle of widget.
@ TopLeft
Top-left of widget.
@ TopRight
Top-right of widget.
void anchorWidgetChanged(QWidget *widget)
Emitted when the anchor widget changes.
QWidget * anchorWidget()
Returns the widget that the floating widget is "anchored" tto.
AnchorPoint anchorPoint() const
Returns the floating widget's anchor point, which corresponds to the point on the widget which should...
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
record about vertex coordinates and index of anchor to which it is snapped