def dockWidget(self, widget, title, area): """ Adds a widget as a docked widget. Returns the added dockWidget """ assert widget.parent() is None, "Widget already has a parent" dockWidget = QtWidgets.QDockWidget(title, parent=self) # Use dock2 as name to reset at upgrade dockWidget.setObjectName("dock2_" + string_to_identifier(title)) # Use doc dockWidget.setWidget(widget) self.addDockWidget(area, dockWidget) self.panelsMenu.addAction(dockWidget.toggleViewAction()) return dockWidget
def dockWidget(self, widget, title, area): """ Adds a widget as a docked widget. Returns the added dockWidget """ assert widget.parent() is None, "Widget already has a parent" dockWidget = QtWidgets.QDockWidget(title, parent=self) dockWidget.setObjectName("dock_" + string_to_identifier(title)) dockWidget.setWidget(widget) # Prevent parent context menu (with e.g. 'set inspector" option) to be displayed. dockWidget.setContextMenuPolicy(Qt.PreventContextMenu) self.addDockWidget(area, dockWidget) self.viewMenu.addAction(dockWidget.toggleViewAction()) return dockWidget