QgsFloatingWidget class

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.

Derived classes

class QgsUserInputWidget
The QgsUserInputWidget class is a floating widget that shall be used to display widgets for user inputs.

Public types

enum AnchorPoint { TopLeft, TopMiddle, TopRight, MiddleLeft, Middle, MiddleRight, BottomLeft, BottomMiddle, BottomRight }
Reference points for anchoring widget position.

Constructors, destructors, conversion operators

QgsFloatingWidget(QWidget* parent = nullptr)
Constructor for QgsFloatingWidget.

Public functions

auto anchorPoint() const -> AnchorPoint
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.
auto anchorWidget() -> QWidget*
Returns the widget that the floating widget is "anchored" tto.
auto anchorWidgetPoint() const -> AnchorPoint
Returns the anchor widget's anchor point, which corresponds to the point on the anchor widget which the floating widget should "attach" to.
void setAnchorPoint(AnchorPoint point)
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.
void setAnchorWidget(QWidget* widget)
Sets the widget to "anchor" the floating widget to.
void setAnchorWidgetPoint(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.

Signals

void anchorPointChanged(QgsFloatingWidget::AnchorPoint point)
Emitted when the anchor point changes.
void anchorWidgetChanged(QWidget* widget)
Emitted when the anchor widget changes.
void anchorWidgetPointChanged(QgsFloatingWidget::AnchorPoint point)
Emitted when the anchor widget point changes.

Enum documentation

enum QgsFloatingWidget::AnchorPoint

Reference points for anchoring widget position.

Enumerators
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.

Function documentation

QgsFloatingWidget::QgsFloatingWidget(QWidget* parent = nullptr)

Constructor for QgsFloatingWidget.

Parameters
parent parent widget

AnchorPoint QgsFloatingWidget::anchorPoint() const

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.

QWidget* QgsFloatingWidget::anchorWidget()

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.

AnchorPoint QgsFloatingWidget::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.

void QgsFloatingWidget::setAnchorPoint(AnchorPoint point)

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.

Parameters
point anchor point

void QgsFloatingWidget::setAnchorWidget(QWidget* widget)

Sets the widget to "anchor" the floating widget to.

Parameters
widget anchor widget. Both the floating widget and the anchor widget must share some common parent.

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.

void QgsFloatingWidget::setAnchorWidgetPoint(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.