Search⌘ K
AI Features

QDockWidget, QStatusBar, and QToolBar

Explore how to use QDockWidget, QStatusBar, and QToolBar classes to build functional and user-friendly PyQt6 interfaces. This lesson guides you through adding menus, toolbars, status bars, and dock widgets, enabling you to create more interactive and polished GUI applications.

QDockWidget and QStatusBar

Toolbars, status bars, and dock widgets can be added to GUIs using framework software. When the mouse pointer is over the "Exit" icon in the toolbar, the status bar at the bottom displays the text "Quit program".

We start by importing the modules which will be required for the application.

Python 3.8
import sys
from PyQt6.QtWidgets import (QApplication, QMainWindow, QStatusBar, QTextEdit, QToolBar, QDockWidget)
from PyQt6.QtCore import Qt, QSize
from PyQt6.QtGui import QIcon, QAction

Then we initialize the window and display its contents on the screen, and we also set a new central widget for our main window.

Python 3.8
class BasicMenu(QMainWindow):
def __init__(self):
super().__init__()
self.initializeUI()
def initializeUI(self):
self.setGeometry(100, 100, 350, 350) # x, y, width, height
self.setWindowTitle('Basic Menu Example 2')
self.setCentralWidget(QTextEdit())
self.createMenu()
self.createToolBar()
self.createDockWidget()
self.show()

After that, we create a menu bar and menu actions. First, we develop actions for ...