QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
Public Types | Public Slots | Public Member Functions | Protected Member Functions | List of all members
QgsStatusBar Class Reference

A proxy widget for QStatusBar. More...

#include <qgsstatusbar.h>

Inheritance diagram for QgsStatusBar:
Inheritance graph
[legend]

Public Types

enum  Anchor { AnchorLeft = 0, AnchorRight }
 Placement anchor for widgets. More...
 

Public Slots

void clearMessage ()
 Removes any temporary message being shown. More...
 
void setParentStatusBar (QStatusBar *statusBar)
 Sets the parent status bar. More...
 
void showMessage (const QString &message, int timeout=0)
 Displays the given message for the specified number of milli-seconds (timeout). More...
 

Public Member Functions

 QgsStatusBar (QWidget *parent=nullptr)
 Constructor for QgsStatusBar. More...
 
void addPermanentWidget (QWidget *widget, int stretch=0, Anchor anchor=AnchorRight)
 Adds the given widget permanently to this status bar, reparenting the widget if it isn't already a child of this object. More...
 
QString currentMessage () const
 Returns the current message shown in the status bar. More...
 
void removeWidget (QWidget *widget)
 Removes a widget from the status bar. More...
 

Protected Member Functions

void changeEvent (QEvent *event) override
 

Detailed Description

A proxy widget for QStatusBar.

Unlike QStatusBar, QgsStatusBar allows finer control of widget placement, including the option to locate permanent widgets on the left side of the bar.

QgsStatusBar is designed to be embedded into an existing window's QStatusBar, as a permanent widget. This allows reuse of the special QStatusBar handling for resize grips and other platform specific status bar tweaks.

Instead of adding child widgets and showing messages directly in the window's status bar, these widgets (and messages) should instead be added into the embedded QgsStatusBar.

Since
QGIS 3.0

Definition at line 46 of file qgsstatusbar.h.

Member Enumeration Documentation

◆ Anchor

Placement anchor for widgets.

Enumerator
AnchorLeft 

Anchor widget to left of status bar.

AnchorRight 

Anchor widget to right of status bar.

Definition at line 53 of file qgsstatusbar.h.

Constructor & Destructor Documentation

◆ QgsStatusBar()

QgsStatusBar::QgsStatusBar ( QWidget *  parent = nullptr)

Constructor for QgsStatusBar.

Definition at line 26 of file qgsstatusbar.cpp.

Member Function Documentation

◆ addPermanentWidget()

void QgsStatusBar::addPermanentWidget ( QWidget *  widget,
int  stretch = 0,
Anchor  anchor = AnchorRight 
)

Adds the given widget permanently to this status bar, reparenting the widget if it isn't already a child of this object.

The stretch parameter is used to compute a suitable size for the given widget as the status bar grows and shrinks. The default stretch factor is 0, i.e giving the widget a minimum of space.

The anchor parameter controls which side of the status bar the widget should be anchored to.

Definition at line 45 of file qgsstatusbar.cpp.

◆ changeEvent()

void QgsStatusBar::changeEvent ( QEvent *  event)
overrideprotected

Definition at line 105 of file qgsstatusbar.cpp.

◆ clearMessage

void QgsStatusBar::clearMessage ( )
slot

Removes any temporary message being shown.

See also
showMessage()

Definition at line 89 of file qgsstatusbar.cpp.

◆ currentMessage()

QString QgsStatusBar::currentMessage ( ) const

Returns the current message shown in the status bar.

See also
showMessage()

Definition at line 64 of file qgsstatusbar.cpp.

◆ removeWidget()

void QgsStatusBar::removeWidget ( QWidget *  widget)

Removes a widget from the status bar.

Ownership of the widget remains unchanged, and the widget itself is not deleted.

Definition at line 59 of file qgsstatusbar.cpp.

◆ setParentStatusBar

void QgsStatusBar::setParentStatusBar ( QStatusBar *  statusBar)
slot

Sets the parent status bar.

Messages that are shown on the parent status bar will be intercepted and shown on this status bar too.

Since
QGIS 3.8

Definition at line 94 of file qgsstatusbar.cpp.

◆ showMessage

void QgsStatusBar::showMessage ( const QString &  message,
int  timeout = 0 
)
slot

Displays the given message for the specified number of milli-seconds (timeout).

If timeout is 0 (default), the message remains displayed until the clearMessage() slot is called or until the showMessage() slot is called again to change the message.

See also
clearMessage()
currentMessage()

Definition at line 69 of file qgsstatusbar.cpp.


The documentation for this class was generated from the following files: