I am using the answer to Adding custom panel to QGIS to add a custom panel to my existing custom QGIS plug-in. So far, the plug-in only uses modal dialogues. I try to show the widget from the callback of a toolbar menu option:
file_widget = QgsFileWidget()
file_widget.setObjectName('filewidget_example')
container = QDockWidget('A file widget in a dockable container')
container.setWidget(file_widget)
container.setVisible(True)
self.iface.addDockWidget(Qt.RightDockWidgetArea, container)
On execution, the right-hand side of the map view slides to the left to make room for the panel, but nothing is shown and after about half a second, the view slides back. There is nothing in the logs. I can show
the widget, so it is being created properly. The interface self.iface
is being used a lot elsewhere in the plug-in, so I know this is valid.
I have tried moving the code so that it is executed at the end of the GUI initialisation, but nothing happens at all.
Any suggestions as to why this is not appearing properly and what I need to do?