6

When writing PyQGIS scripts, especially processing script and expression function, I come across the term context. I use it, but I don't know what all contexts mean actually.

There are also Qgs***Context classes. For example, QgsExpressionContext, QgsSymbolWidgetContext, QgsGeometryCheckContext, QgsAttributeEditorContext, ... .

What does context refer in all those class names and in some methods in PyQGIS?

2
  • 1
    This question is different from What are parameters and context in PyQGIS processAlgorithm function?. The other is about how to define our own context variable. Dec 25 '21 at 13:39
  • 2
    In basic software engineering, "context" is used to connote ancillary information needed to generate results, usually dynamic, and associated with processing or the state of processing. It is especially used in interfaces where a developer provides a user function, as custom data to be provided to the custom function to maintain state information on the progress of execution. There's usually a setter for a function in the form of setFunction(int (*fn)(void *data, void *context), void *context) (where data is something to be processed (a row or object), and context is user-provided).
    – Vince
    Dec 25 '21 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.