How to Create an External Class
A class, as its name suggests, is a template that is used to provide different functionality. It contains a name, description and other meta data. When a program is written using an external class, it will use the MetaClassLoader to load the class. There are many types of external classes.
A Q_DECLARE_EXTERNAL_CLASS macro is used to create an external class. It will then automatically get loaded when the application is created and available to be used. A Q_ADD_EXTERNAL_CLASS macro is used to add another external class. The same goes for the Q_ADD_SHOW_EXTERNAL_CLASS macro. However, the Q_DELINE_EXTERNAL_CLASS macro is only useful when the class is used within a widget.
An external class can also be loaded with Q_ADD_COUNTED_EXTERNAL_CLASS macro. This way, all the files which are used to create the external class will be loaded at the same time. There are two main methods to create an external class, the first is called the external constructor, while the second is called the external destructor.
When creating an external class, there are several steps to take to ensure that the external class is able to be read and created by the application. First, the external class should be created as an empty class. Then it should be assigned to the static variable external_class which can be accessed whenever the external class needs to be used.
After the external class has been assigned, it should be initialized, which should take place just before the function returns. It should be placed after the return statement using a label as the function to reference, so that it is visible to all functions that call the function. After the external class is set up, the external variable internal_class that was created should be made available to the function, so that the external class can be accessed from inside the application. A new function, the ExternalFunction, can then be used to access it. Whenever the function is called, it should call the internal_function with the static variable of the external class.
External functions that are accessed from the application need to be registered to be part of the class. These functions can be registered using the register function, and there is a list of registered functions available. When a class is accessed, the external function should use the static function to retrieve the function, so that the function is available to other functions that make use of the same external class. The last step is to call the exit function, which does exactly as the name suggests.
If you want to know more about how to create and use an external class, check out the documentation for the internal function of your application for further information. The documentation for the external function can be found on the official website for the application. When the external function is used, it will be accessible as external function that is defined with the name of the external class.