QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsApplicationExitBlockerInterface Class Referenceabstract

An interface that may be implemented to allow plugins or scripts to temporarily block the QGIS application from exiting. More...

#include <qgsapplicationexitblockerinterface.h>

Public Member Functions

virtual ~QgsApplicationExitBlockerInterface ()
 
virtual bool allowExit ()=0
 Called whenever the QGIS application has been asked to exit by a user.
 

Detailed Description

An interface that may be implemented to allow plugins or scripts to temporarily block the QGIS application from exiting.

This interface allows plugins to implement custom logic to determine whether it is safe for the application to exit, e.g. by checking whether the plugin or script has any unsaved changes which should be saved or discarded before allowing QGIS to exit.

QgsApplicationExitBlockerInterface are registered via the iface object:

Example

class MyPluginExitBlocker(QgsApplicationExitBlockerInterface):
def allowExit(self):
if self.has_unsaved_changes():
# show a warning prompt
# ...
# prevent QGIS application from exiting
return False
# allow QGIS application to exit
return True
my_blocker = MyPluginExitBlocker()
iface.registerApplicationExitBlocker(my_blocker)
An interface that may be implemented to allow plugins or scripts to temporarily block the QGIS applic...
Since
QGIS 3.16

Definition at line 55 of file qgsapplicationexitblockerinterface.h.

Constructor & Destructor Documentation

◆ ~QgsApplicationExitBlockerInterface()

QgsApplicationExitBlockerInterface::~QgsApplicationExitBlockerInterface ( )
virtualdefault

Member Function Documentation

◆ allowExit()

virtual bool QgsApplicationExitBlockerInterface::allowExit ( )
pure virtual

Called whenever the QGIS application has been asked to exit by a user.

The subclass can use this method to implement custom logic handling whether it is safe for the application to exit, e.g. by checking whether the plugin or script has any unsaved changes which should be saved or discarded before allowing QGIS to exit.

The implementation should return true if it is safe for QGIS to exit, or false if it wishes to prevent the application from exiting.

Note
It is safe to use GUI widgets in implementations of this function, including message boxes or custom dialogs with event loops.

The documentation for this class was generated from the following files: