I have tried the QgsBrowserModel but it doesn't seem to work. I am not even sure if that is the right class to use.

The problem is that I add WMS and database connections through a plugin but they won't show up in the QGIS Browser until I hit the refresh button

QGIS Browser

Do you know a way to refresh the Browser through the QGIS API? And if so, could this be applied to all currently opened instances of QGIS?

1 Answer 1


Try the following

Updated answer due to comment feedback

iface.mainWindow().findChildren(QWidget, 'Browser')[0].refresh()
# If you need to refresh the second browser panel too
iface.mainWindow().findChildren(QWidget, 'Browser2')[0].refresh()

Old answer

widget = iface.mainWindow().findChildren(QWidget, 'Browser')[0]
widget2 = iface.mainWindow().findChildren(QWidget, 'Browser2')[0]

widgetAction = widget.findChildren(QAction, 'mActionRefresh')

widgetAction2 = widget2.findChildren(QAction, 'mActionRefresh')

If there is a shortcut, would be glad to learn about it

  • 1
    A bit quicker: 'iface.mainWindow().findChildren(QWidget, 'Browser')[0].refresh()' I can't find a shortcut to the QgsBrowserDockWidget. Commented Jul 29, 2020 at 12:59
  • It refreshes the widget not the list inside the widget.
    – ThomasG77
    Commented Jul 29, 2020 at 13:51
  • 2
    It's the same. The 'mActionRefreshButton' is connected to the 'refresh' action on the widget. So you can skip finding the button and trigger it. You can see that in the source code (line 98): github.com/qgis/QGIS/blob/… Commented Jul 30, 2020 at 6:08
  • Sorry for the delayed reply. And thank you all very much, both Versions work perfectly, but it only works for the Qgis Instance from which the code is run. Lets say I have 2 Qgis Instances opened, each runs on tehir own profile, can I refresh the browser of profile 2 from the instance of profile 1?
    – breezy
    Commented Aug 3, 2020 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.