As suggested in docs, the QGIS message bar is usually the best option to show short messages communicating with the user.
Is it possible to show the QGIS message bar inside a plugin's guiGUI developed with Qt Designer as shown below?
QGIS guiGUI:
Desired plugin guiGUI:
This would simplify interacting with the user when plugin's window is in full screen mode, hiding qgisQGIS main window.
EDIT after J. Monticolo's answer.
In order to integrate J. Monticolo's code to an existing plugin, I inserted this in its main's run method:
def run(self):
"""Run method that performs all the real work"""
# Create the dialog with elements (after translation) and keep reference
# Only create GUI ONCE in callback, so that it will only load when the plugin is started
if self.first_start == True:
self.first_start = False
self.my_msg_bar = QgsMessageBar()
self.dlg.verticalLayout.insertWidget(0, self.my_msg_bar)
self.my_msg_bar.pushMessage("Welcome", "This plugin is ready at your service.", level=Qgis.Success, duration=-1)
Where verticalLayoutverticalLayout
is an object introduced with Qt Designer:
referenceReference: https://docs.qgis.org/3.16/en/docs/pyqgis_developer_cookbook/communicating.html