I have a main window of my app and two other widgets, that are docked to the right side of the main window. How could I resize the two docked widgets?
"Date" and "Time" widgets must be resized so that they both vertically take half of the space, and horizontally must be both wider.
Here is how I create the window and the widgets:
def __init__(self):
super().__init__()
self.resize(2000, 1200)
self.center()
self.setWindowTitle("ARMS")
self.date = QDockWidget("Date", self)
self.time = QDockWidget("Time", self)
self.dateWidget = QWidget()
self.timeWidget = QListWidget()
self.timeWidget.addItems(['0', '3', '6', '9', '12', '15', '18', '21'])
self.date.setWidget(self.dateWidget)
self.date.setFloating(False)
self.time.setWidget(self.timeWidget)
self.time.setFloating(False)
self.setCentralWidget(QTextEdit())
self.addDockWidget(Qt.RightDockWidgetArea, self.date)
self.addDockWidget(Qt.RightDockWidgetArea, self.time)
I've tried the following, but it didn't work:
self.date.resize(800, 1000)
# and
self.dateWidget.resize(800, 1000)
Also, is there a way to make those two widgets undraggable and unclosable; just lock them at place the way they are?
CodePudding user response:
Thanks to @ekhumoro,
QMainWindow.resizeDocks and QDockWidget.setFeatures are the answer.