PyQt6 Bindings for (the amazing) Qt-Advanced-Docking-System
pip install PyQt6Ads
Please see documentation in the upstream repo.
See also examples in this repo.
The autogenerated type stubs are also useful for understanding the API.
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QAction
from PyQt6.QtWidgets import QMainWindow, QLabel
import PyQt6Ads as ads
class MainWindow(QMainWindow):
def __init__(self) -> None:
super().__init__()
# create the dock manager
# If the parent is a QMainWindow, DockManager sets itself as the central widget.
self.dock_manager = ads.CDockManager(self)
# create an example widget to place inside the dock widget
lbl = QLabel()
lbl.setWordWrap(True)
lbl.setAlignment(Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignLeft)
lbl.setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.")
# create a dock widget with the title "Label 1"
# and set the created label as the dock widget content
dw = ads.CDockWidget("Label 1")
dw.setWidget(lbl)
# add the toggleViewAction of the dock widget to the menu
# to give the user the possibility to show the dock widget if it has been closed
self.menuView = self.menuBar().addMenu("View")
self.menuView.addAction(dw.toggleViewAction())
# add the dock widget to the top dock widget area
self.dock_manager.addDockWidget(ads.DockWidgetArea.TopDockWidgetArea, dw)
- For PySide6: See https://github.com/mborgerson/pyside6_qtads
- For PyQt5: See https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System#pyqt5 (in the upstream repo)