import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *class CustomDock(QDockWidget):def __init__(self, title: str, parent=None):super().__init__(title, parent)"""停靠栏的头部"""h_layout = QHBoxLayout()h_layout.setContentsMargins(0, 7, 0, 7)h_layout.setSpacing(0)self.label = QLabel("知识点")self.btn_hide = QPushButton(QIcon("hide.jpg"), "", self)# self.btn_hide.setStyleSheet("background-color: #f0f0f0")h_layout.addWidget(self.label)# h_layout.addWidget(QLineEdit())h_layout.addWidget(self.btn_hide,alignment=Qt.AlignRight)title_bar_widget = QWidget()title_bar_widget.setLayout(h_layout)self.setTitleBarWidget(title_bar_widget)"""停靠栏的内容"""self.title_list = QListWidget(self)self.title_list.addItems([str(i) for i in range(100)])self.setWidget(self.title_list)class MainWindow(QMainWindow):def __init__(self):super().__init__()self.setCentralWidget(QTextEdit())dock = CustomDock("你好", self)self.addDockWidget(Qt.BottomDockWidgetArea, dock)if __name__ == '__main__':app = QApplication(sys.argv)window = MainWindow()window.setFont(QFont("Arial", 12))window.show()sys.exit(app.exec_())