<div dir="ltr"><div>The way to achieve this would be to override the closeEvent() method of the main QGIs Window. I don't know how to do that. But you can do that on your plugin widget - which will at least prevent that dialog to be closed if certain conditions are not met.</div><div><br></div><div> def closeEvent(self, event):<br> if condition:</div><div> event.accept()<br></div><div> else:</div><div> event.ignore()</div><div><table cellpadding="0" cellspacing="0" style="border-spacing:0px;border-collapse:collapse;color:rgb(68,68,68);width:480px;font-size:10pt;font-family:Arial,sans-serif;line-height:normal"><tbody><tr><td valign="top" style="padding:10px 0px 12px;width:160px;vertical-align:top"><a href="https://spatialthoughts.com/" style="background-color:transparent;color:rgb(51,122,183)" target="_blank"><img border="0" alt="Logo" width="141" src="https://spatialthoughts685850346.files.wordpress.com/2019/12/spatial_thoughts_logo.png" style="border:0px;vertical-align:middle;width:141px;height:auto"></a></td><td style="padding:6px 0px;width:320px"><table cellpadding="0" cellspacing="0" style="border-spacing:0px;border-collapse:collapse;background-color:transparent"><tbody><tr><td style="padding:0px;font-size:12pt;font-family:Arial,sans-serif;font-weight:bold;color:rgb(61,60,63)"><span style="color:rgb(0,175,239)">Ujaval Gandhi</span></td></tr><tr><td style="padding:0px 0px 11px;font-size:10pt;font-family:Arial,sans-serif;color:rgb(61,60,63)"><span style="color:rgb(0,175,239)">Spatial Thoughts</span></td></tr><tr><td style="padding:0px;font-size:10pt;font-family:Arial,sans-serif;color:rgb(155,155,155)">mobile: +91-8095684687</td></tr><tr><td style="padding:0px;font-size:10pt;font-family:Arial,sans-serif;color:rgb(155,155,155)">email: <span style="color:rgb(23,147,210)"><a href="mailto:ujaval@spatialthoughts.com" target="_blank">ujaval@spatialthoughts.com</a></span></td></tr><tr><td style="padding:6px 0px 0px"><span style="display:inline-block;height:22px"><a href="https://www.linkedin.com/in/spatialthoughts/" style="background-color:transparent;color:rgb(51,122,183)" target="_blank"><img alt="LinkedIn icon" border="0" width="23" height="23" src="https://codetwocdn.azureedge.net/images/mail-signatures/generator/elegant-logo/ln.png" style="border:0px;vertical-align:middle;height:20px;width:20px"></a> <a href="https://twitter.com/spatialthoughts" style="background-color:transparent;color:rgb(51,122,183)" target="_blank"><img alt="Twitter icon" border="0" width="23" height="23" src="https://codetwocdn.azureedge.net/images/mail-signatures/generator/elegant-logo/tt.png" style="border:0px;vertical-align:middle;height:20px;width:20px"></a> </span></td></tr></tbody></table></td></tr><tr><td colspan="2" style="padding:8px 0px 0px;border-top:1px solid rgb(23,147,210);width:480px;font-family:Arial,sans-serif;color:rgb(155,155,155);text-align:justify">Subscribe to our newsletter <a href="http://bit.ly/spatialthoughts-newsletter" target="_blank">http://bit.ly/spatialthoughts-newsletter</a></td></tr></tbody></table></div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div></div></div></div></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 26, 2020 at 10:02 AM Jan Růžička <<a href="mailto:jan.ruzicka.vsb@gmail.com">jan.ruzicka.vsb@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thank you very much, the same is possible in the unload method of the plugin, but the question is how to stop QGIS to exit.<div>I need to inform the user that he did not enter the result of the search and keep QGIS open for the user to enter the result.</div><div><br></div><div>The possible workaround may be, to run the QGIS again, when it quits, but I thought that there may be some better way.</div><div><br clear="all"><div><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="font-size:12.8px">Jan Růžička, Ph.D.</span><br style="font-size:12.8px"><span style="font-size:12.8px">freelancer, </span><span style="font-size:12.8px">researcher and </span><span style="font-size:12.8px">volontaire</span></div><div>Geoinformatics<div>tel: +420 775 032 091<br></div><div><span style="font-size:12.8px">e-mail: <a href="http://jan.ruzicka.vsb.cz/" style="color:rgb(17,85,204)" target="_blank">jan.ruzicka.vsb@gmail.com</a></span><br></div></div><div><a href="http://github.com/ruz76/" target="_blank">http://github.com/ruz76/</a></div><div><a href="http://gismentors.eu/" target="_blank">http://gismentors.eu/</a></div><div><a href="http://dolnilhota.info/" target="_blank">http://dolnilhota.info/</a></div></div></div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 25 juin 2020 à 17:25, Ujaval Gandhi <<a href="mailto:ujaval@spatialthoughts.com" target="_blank">ujaval@spatialthoughts.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I saw that there is a aboutToQuit signal emitted just before a QApplication exists. The following works from QGIS Python Console.</div><div><br></div>def test():<br> with open('/tmp/test.txt', 'w') as f:<br> f.write('wrote while exiting')<br><br>qApp.aboutToQuit.connect(test)<br clear="all"><div><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div></div><div><table cellpadding="0" cellspacing="0" style="border-spacing:0px;border-collapse:collapse;color:rgb(68,68,68);width:480px;font-size:10pt;font-family:Arial,sans-serif;line-height:normal"><tbody><tr><td valign="top" style="padding:10px 0px 12px;width:160px;vertical-align:top"><a href="https://spatialthoughts.com/" style="background-color:transparent;color:rgb(51,122,183)" target="_blank"><img border="0" alt="Logo" width="141" src="https://spatialthoughts685850346.files.wordpress.com/2019/12/spatial_thoughts_logo.png" style="border: 0px; vertical-align: middle; width: 141px; height: auto;"></a></td><td style="padding:6px 0px;width:320px"><table cellpadding="0" cellspacing="0" style="border-spacing:0px;border-collapse:collapse;background-color:transparent"><tbody><tr><td style="padding:0px;font-size:12pt;font-family:Arial,sans-serif;font-weight:bold;color:rgb(61,60,63)"><span style="color:rgb(0,175,239)">Ujaval Gandhi</span></td></tr><tr><td style="padding:0px 0px 11px;font-size:10pt;font-family:Arial,sans-serif;color:rgb(61,60,63)"><span style="color:rgb(0,175,239)">Spatial Thoughts</span></td></tr><tr><td style="padding:0px;font-size:10pt;font-family:Arial,sans-serif;color:rgb(155,155,155)"><span>mobile: +91-8095684687</span></td></tr><tr><td style="padding:0px;font-size:10pt;font-family:Arial,sans-serif;color:rgb(155,155,155)"><span>email: </span><span style="color:rgb(23,147,210)"><a href="mailto:ujaval@spatialthoughts.com" target="_blank">ujaval@spatialthoughts.com</a></span></td></tr><tr><td style="padding:6px 0px 0px"><span style="display:inline-block;height:22px"><span><a href="https://www.linkedin.com/in/spatialthoughts/" style="background-color:transparent;color:rgb(51,122,183)" target="_blank"><img alt="LinkedIn icon" border="0" width="23" height="23" src="https://codetwocdn.azureedge.net/images/mail-signatures/generator/elegant-logo/ln.png" style="border: 0px; vertical-align: middle; height: 20px; width: 20px;"></a> </span><span><a href="https://twitter.com/spatialthoughts" style="background-color:transparent;color:rgb(51,122,183)" target="_blank"><img alt="Twitter icon" border="0" width="23" height="23" src="https://codetwocdn.azureedge.net/images/mail-signatures/generator/elegant-logo/tt.png" style="border: 0px; vertical-align: middle; height: 20px; width: 20px;"></a> </span></span></td></tr></tbody></table></td></tr><tr><td colspan="2" style="padding:8px 0px 0px;border-top:1px solid rgb(23,147,210);width:480px;font-family:Arial,sans-serif;color:rgb(155,155,155);text-align:justify"><span>Subscribe to our newsletter <a href="http://bit.ly/spatialthoughts-newsletter" target="_blank">http://bit.ly/spatialthoughts-newsletter</a></span></td></tr></tbody></table><br></div></div></div></div></div></div></div></div></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 25, 2020 at 5:00 PM Jan Růžička <<a href="mailto:jan.ruzicka.vsb@gmail.com" target="_blank">jan.ruzicka.vsb@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear developers,<div><br></div><div>I have developed a plugin for the Police of the Czech Republic for Search and Rescue operations. It works quite well, but one important feature is missing.</div><div><br></div><div>After the search event is finished the user should enter the result of the search.</div><div><br></div><div>I was not able to find a way to catch an event when the user closes the whole QGIS. I need similar functionality like when closing in the case of a dirty project (no all changes were saved).</div><div><br></div><div>I have searched a lot and did not find any solution. I was able to catch the unload event of the plugin, but I did not find a way to keep QGIS opened.</div><div><br></div><div>Any help appreciated</div><div><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="font-size:12.8px">Jan Růžička, Ph.D.</span><br style="font-size:12.8px"><span style="font-size:12.8px">freelancer, </span><span style="font-size:12.8px">researcher and </span><span style="font-size:12.8px">volontaire</span></div><div>Geoinformatics<div>tel: +420 775 032 091<br></div><div><span style="font-size:12.8px">e-mail: <a href="http://jan.ruzicka.vsb.cz/" style="color:rgb(17,85,204)" target="_blank">jan.ruzicka.vsb@gmail.com</a></span><br></div></div><div><a href="http://github.com/ruz76/" target="_blank">http://github.com/ruz76/</a></div><div><a href="http://gismentors.eu/" target="_blank">http://gismentors.eu/</a></div><div><a href="http://dolnilhota.info/" target="_blank">http://dolnilhota.info/</a></div></div></div></div></div></div></div></div></div></div></div>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></blockquote></div>
</blockquote></div>
</blockquote></div>