下面的剪辑显示了QDockWidget
通过拖动选项卡(而不是标题栏)在停靠区域之间拖动 - 但当我使用 PyQt 5.15.0 尝试此操作时,它不起作用,选项卡不会分离。我怎样才能启用这种行为?
我的代码:
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt
if __name__ == "__main__":
app = QtWidgets.QApplication([])
main = QtWidgets.QMainWindow()
dock1 = QtWidgets.QDockWidget("Blue")
dock2 = QtWidgets.QDockWidget("Green")
dock3 = QtWidgets.QDockWidget("Red")
content1 = QtWidgets.QWidget()
content1.setStyleSheet("background-color:blue;")
content2 = QtWidgets.QWidget()
content2.setStyleSheet("background-color:green;")
content3 = QtWidgets.QWidget()
content3.setStyleSheet("background-color:red;")
dock1.setWidget(content1)
dock2.setWidget(content2)
dock3.setWidget(content3)
dock1.setAllowedAreas(Qt.AllDockWidgetAreas)
dock2.setAllowedAreas(Qt.AllDockWidgetAreas)
dock3.setAllowedAreas(Qt.AllDockWidgetAreas)
main.addDockWidget(Qt.LeftDockWidgetArea, dock1)
main.tabifyDockWidget(dock1, dock2)
main.addDockWidget(Qt.RightDockWidgetArea, dock3)
main.resize(400, 200)
main.show()
app.exec_()
一只斗牛犬
LEATH
相关分类