2016-04-26 15:54:30 +10:00
|
|
|
/** \ingroup gui
|
|
|
|
* \class QgsFloatingWidget
|
|
|
|
* A QWidget subclass for creating widgets which float outside of the normal Qt layout
|
|
|
|
* system. Floating widgets use an "anchor widget" to determine how they are anchored
|
|
|
|
* within their parent widget.
|
|
|
|
* \note Added in version 2.16
|
|
|
|
*/
|
|
|
|
|
|
|
|
class QgsFloatingWidget : QWidget
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsfloatingwidget.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! Reference points for anchoring widget position
|
|
|
|
enum AnchorPoint
|
|
|
|
{
|
|
|
|
TopLeft, //!< Top-left of widget
|
|
|
|
TopMiddle, //!< Top center of widget
|
|
|
|
TopRight, //!< Top-right of widget
|
|
|
|
MiddleLeft, //!< Middle left of widget
|
|
|
|
Middle, //!< Middle of widget
|
|
|
|
MiddleRight, //!< Middle right of widget
|
|
|
|
BottomLeft, //!< Bottom-left of widget
|
|
|
|
BottomMiddle, //!< Bottom center of widget
|
|
|
|
BottomRight, //!< Bottom-right of widget
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Constructor for QgsFloatingWidget.
|
|
|
|
* @param parent parent widget
|
|
|
|
*/
|
2017-05-01 16:42:33 +02:00
|
|
|
QgsFloatingWidget( QWidget *parent /TransferThis/ = nullptr );
|
2016-04-26 15:54:30 +10:00
|
|
|
|
|
|
|
/** Sets the widget to "anchor" the floating widget to. The floating widget will be repositioned whenever the
|
|
|
|
* anchor widget moves or is resized so that it maintains the same relative position to the anchor widget.
|
|
|
|
* @param widget anchor widget. Both the floating widget and the anchor widget must share some common parent.
|
|
|
|
* @see anchorWidget()
|
|
|
|
*/
|
2017-05-01 16:42:33 +02:00
|
|
|
void setAnchorWidget( QWidget *widget );
|
2016-04-26 15:54:30 +10:00
|
|
|
|
|
|
|
/** Returns the widget that the floating widget is "anchored" tto. The floating widget will be repositioned whenever the
|
|
|
|
* anchor widget moves or is resized so that it maintains the same relative position to the anchor widget.
|
|
|
|
* @see setAnchorWidget()
|
|
|
|
*/
|
2017-05-01 16:42:33 +02:00
|
|
|
QWidget *anchorWidget();
|
2016-04-26 15:54:30 +10:00
|
|
|
|
|
|
|
/** Returns the floating widget's anchor point, which corresponds to the point on the widget which should remain
|
|
|
|
* fixed in the same relative position whenever the widget's parent is resized or moved.
|
|
|
|
* @see setAnchorPoint()
|
|
|
|
*/
|
|
|
|
AnchorPoint anchorPoint() const;
|
|
|
|
|
|
|
|
/** Sets the floating widget's anchor point, which corresponds to the point on the widget which should remain
|
|
|
|
* fixed in the same relative position whenever the widget's parent is resized or moved.
|
|
|
|
* @param point anchor point
|
|
|
|
* @see anchorPoint()
|
|
|
|
*/
|
|
|
|
void setAnchorPoint( AnchorPoint point );
|
|
|
|
|
|
|
|
/** Returns the anchor widget's anchor point, which corresponds to the point on the anchor widget which
|
|
|
|
* the floating widget should "attach" to. The floating widget should remain fixed in the same relative position
|
|
|
|
* to this anchor widget whenever the widget's parent is resized or moved.
|
|
|
|
* @see setAnchorWidgetPoint()
|
|
|
|
*/
|
|
|
|
AnchorPoint anchorWidgetPoint() const;
|
|
|
|
|
|
|
|
/** Returns the anchor widget's anchor point, which corresponds to the point on the anchor widget which
|
|
|
|
* the floating widget should "attach" to. The floating widget should remain fixed in the same relative position
|
|
|
|
* to this anchor widget whenever the widget's parent is resized or moved.
|
|
|
|
* @see setAnchorWidgetPoint()
|
|
|
|
*/
|
|
|
|
void setAnchorWidgetPoint( AnchorPoint point );
|
|
|
|
|
2016-12-15 13:22:39 +10:00
|
|
|
signals:
|
|
|
|
|
|
|
|
//! Emitted when the anchor widget changes
|
2017-05-01 16:42:33 +02:00
|
|
|
void anchorWidgetChanged( QWidget *widget );
|
2016-12-15 13:22:39 +10:00
|
|
|
|
|
|
|
//! Emitted when the anchor point changes
|
|
|
|
void anchorPointChanged( AnchorPoint point );
|
|
|
|
|
|
|
|
//! Emitted when the anchor widget point changes
|
|
|
|
void anchorWidgetPointChanged( AnchorPoint point );
|
|
|
|
|
2016-04-26 15:54:30 +10:00
|
|
|
protected:
|
2017-05-01 16:42:33 +02:00
|
|
|
void showEvent( QShowEvent *e );
|
|
|
|
virtual void paintEvent( QPaintEvent *e );
|
2016-04-26 15:54:30 +10:00
|
|
|
|
|
|
|
};
|