| CARVIEW |
Navigation
QStatusBar¶
- PyQt6.QtWidgets.QStatusBar
Inherits from QWidget.
Description¶
The QStatusBar class provides a horizontal bar suitable for presenting status information.
Each status indicator falls into one of three categories:
Temporary - briefly occupies most of the status bar. Used to explain tool tip texts or menu entries, for example.
Normal - occupies part of the status bar and may be hidden by temporary messages. Used to display the page and line number in a word processor, for example.
Permanent - is never hidden. Used for important mode indications, for example, some applications put a Caps Lock indicator in the status bar.
QStatusBar lets you display all three types of indicators.
Typically, a request for the status bar functionality occurs in relation to a QMainWindow object. QMainWindow provides a main application window, with a menu bar, tool bars, dock widgets and a status bar around a large central widget. The status bar can be retrieved using the statusBar() function, and replaced using the setStatusBar() function.
Use the showMessage() slot to display a temporary message:
# This code needs porting to Python.
# /****************************************************************************
# **
# ** Copyright (C) 2016 The Qt Company Ltd.
# ** Contact: https://www.qt.io/licensing/
# **
# ** This file is part of the documentation of the Qt Toolkit.
# **
# ** $QT_BEGIN_LICENSE:BSD$
# ** Commercial License Usage
# ** Licensees holding valid commercial Qt licenses may use this file in
# ** accordance with the commercial license agreement provided with the
# ** Software or, alternatively, in accordance with the terms contained in
# ** a written agreement between you and The Qt Company. For licensing terms
# ** and conditions see https://www.qt.io/terms-conditions. For further
# ** information use the contact form at https://www.qt.io/contact-us.
# **
# ** BSD License Usage
# ** Alternatively, you may use this file under the terms of the BSD license
# ** as follows:
# **
# ** "Redistribution and use in source and binary forms, with or without
# ** modification, are permitted provided that the following conditions are
# ** met:
# ** * Redistributions of source code must retain the above copyright
# ** notice, this list of conditions and the following disclaimer.
# ** * Redistributions in binary form must reproduce the above copyright
# ** notice, this list of conditions and the following disclaimer in
# ** the documentation and/or other materials provided with the
# ** distribution.
# ** * Neither the name of The Qt Company Ltd nor the names of its
# ** contributors may be used to endorse or promote products derived
# ** from this software without specific prior written permission.
# **
# **
# ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
# **
# ** $QT_END_LICENSE$
# **
# ****************************************************************************/
# #! [0]
# statusBar()->addWidget(new MyReadWriteIndication);
# #! [0]
To remove a temporary message, use the clearMessage() slot, or set a time limit when calling showMessage(). For example:
# This code needs porting to Python.
# /****************************************************************************
# **
# ** Copyright (C) 2016 The Qt Company Ltd.
# ** Contact: https://www.qt.io/licensing/
# **
# ** This file is part of the documentation of the Qt Toolkit.
# **
# ** $QT_BEGIN_LICENSE:BSD$
# ** Commercial License Usage
# ** Licensees holding valid commercial Qt licenses may use this file in
# ** accordance with the commercial license agreement provided with the
# ** Software or, alternatively, in accordance with the terms contained in
# ** a written agreement between you and The Qt Company. For licensing terms
# ** and conditions see https://www.qt.io/terms-conditions. For further
# ** information use the contact form at https://www.qt.io/contact-us.
# **
# ** BSD License Usage
# ** Alternatively, you may use this file under the terms of the BSD license
# ** as follows:
# **
# ** "Redistribution and use in source and binary forms, with or without
# ** modification, are permitted provided that the following conditions are
# ** met:
# ** * Redistributions of source code must retain the above copyright
# ** notice, this list of conditions and the following disclaimer.
# ** * Redistributions in binary form must reproduce the above copyright
# ** notice, this list of conditions and the following disclaimer in
# ** the documentation and/or other materials provided with the
# ** distribution.
# ** * Neither the name of The Qt Company Ltd nor the names of its
# ** contributors may be used to endorse or promote products derived
# ** from this software without specific prior written permission.
# **
# **
# ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
# **
# ** $QT_END_LICENSE$
# **
# ****************************************************************************/
# #! [0]
# statusBar()->addWidget(new MyReadWriteIndication);
# #! [0]
Use the currentMessage() function to retrieve the temporary message currently shown. The QStatusBar class also provide the messageChanged signal which is emitted whenever the temporary status message changes.
Normal and Permanent messages are displayed by creating a small widget (QLabel, QProgressBar or even QToolButton) and then adding it to the status bar using the addWidget() or the addPermanentWidget() function. Use the removeWidget() function to remove such messages from the status bar.
# statusBar()->addWidget(new MyReadWriteIndication);
By default QStatusBar provides a QSizeGrip in the lower-right corner. You can disable it using the setSizeGripEnabled() function. Use the isSizeGripEnabled() function to determine the current status of the size grip.
See also
Methods¶
- __init__(parent: QWidget = None)
Constructs a status bar with a size grip and the given parent.
See also
- addPermanentWidget(QWidget, stretch: int = 0)
Adds the given widget permanently to this status bar, reparenting the widget if it isn’t already a child of this QStatusBar 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.
Permanently means that the widget may not be obscured by temporary messages. It is located at the far right of the status bar.
See also
- addWidget(QWidget, stretch: int = 0)
Adds the given widget to this status bar, reparenting the widget if it isn’t already a child of this QStatusBar 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 widget is located to the far left of the first permanent widget (see addPermanentWidget()) and may be obscured by temporary messages.
See also
- clearMessage()
Removes any temporary message being shown.
See also
- currentMessage() → str
Returns the temporary message currently shown, or an empty string if there is no such message.
See also
- event(QEvent) → bool
TODO
- hideOrShow()
Ensures that the right widgets are visible.
Used by the showMessage() and clearMessage() functions.
- insertPermanentWidget(int, QWidget, stretch: int = 0) → int
Inserts the given widget at the given index permanently to this status bar, reparenting the widget if it isn’t already a child of this QStatusBar object. If index is out of range, the widget is appended (in which case it is the actual index of the widget that is returned).
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.
Permanently means that the widget may not be obscured by temporary messages. It is located at the far right of the status bar.
See also
- insertWidget(int, QWidget, stretch: int = 0) → int
Inserts the given widget at the given index to this status bar, reparenting the widget if it isn’t already a child of this QStatusBar object. If index is out of range, the widget is appended (in which case it is the actual index of the widget that is returned).
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 widget is located to the far left of the first permanent widget (see addPermanentWidget()) and may be obscured by temporary messages.
See also
- isSizeGripEnabled() → bool
TODO
- paintEvent(QPaintEvent)
TODO
- reformat()
Changes the status bar’s appearance to account for item changes.
Special subclasses may need this function, but geometry management will usually take care of any necessary rearrangements.
- removeWidget(QWidget)
Removes the specified widget from the status bar.
Note: This function does not delete the widget but hides it. To add the widget again, you must call both the addWidget() and show() functions.
See also
- resizeEvent(QResizeEvent)
TODO
- setSizeGripEnabled(bool)
See also
- showEvent(QShowEvent)
TODO
- showMessage(Optional[str], msecs: int = 0)
Hides the normal status indications and 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.
Note that showMessage() is called to show temporary explanations of tool tip texts, so passing a timeout of 0 is not sufficient to display a permanent message.
See also
Signals¶
- messageChanged(Optional[str])
This signal is emitted whenever the temporary status message changes. The new temporary message is passed in the message parameter which is a null-string when the message has been removed.
See also