This bad boy just does not want to change size to fill the dock widget area. I have tried all sorts of variations with QSizePolicy but nothing seems to work. The size of the QWebView always stays the same. Do I need to write a resize() callback?
Here’s what I have right now:
self.helpwindow = QtGui.QDockWidget("Doc Browser")
self.helpwindow.setAllowedAreas(QtCore.Qt.RightDockWidgetArea)
self.helpwindow.setFeatures(QtGui.QDockWidget.DockWidgetClosable | QtGui.QDockWidget.DockWidgetFloatable)
helpAction = self.helpwindow.toggleViewAction()
helpAction.setText("&Help Browser")
helpAction.setShortcut(QtGui.QKeySequence("F1"))
helpMenu.addAction(helpAction)
self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.helpwindow)
helpbrowser = QtWebKit.QWebView(self.helpwindow)
indexpath = resource_filename(__name__,"help/index.html")
url = QtCore.QUrl("file://" + indexpath)
helpbrowser.load(url)
helpbrowser.show()
helpbrowser.updateGeometry()
helpbrowser.update()
helpbrowser.setMinimumWidth(400)
helpbrowser.setMinimumHeight( self.helpwindow.height())
sizepolicy = helpbrowser.sizePolicy()
sizepolicy.setVerticalPolicy(QtGui.QSizePolicy.MinimumExpanding)
sizepolicy.setHorizontalPolicy(QtGui.QSizePolicy.MinimumExpanding)
I’m using PyQT4 but C++ solutions gladly accepted.
Setting only paren’t wont make QDockWidget manage child widget. You need to call: