[QGIS-Developer] show error message without exiting the plugin

Roberta Fagandini robifagandini at gmail.com
Fri May 3 06:45:01 PDT 2019


Hi all,
I'm developing a plugin and I need to check if some features of the input
vector layer are selected or not. If not I'd like to show an error message
without closing the plugin gui:

This is the code at the moment:

            if self.dlg.checkBox.isChecked():
                check_sel = selectedLayer2.selectedFeatureCount()
                if check_sel > 0:
                    intersec_layer =
QgsProcessingFeatureSourceDefinition(selectedLayer2.id(), True)
                else:
                    self.iface.messageBar().pushCritical("Error", "No
features selected in layer {}.".format(selectedLayer2.name()))
                    return

Any idea?

Thanks
Roberta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190503/22fcf888/attachment.html>


More information about the QGIS-Developer mailing list