Writing dynamic plugins
Static plugins provide a convenient way to distribute your applications. However, this always requires a rebuild of the main program. By contrast, dynamic plugins are much more flexible since they're linked dynamically. This means the main project, which is painter_demo
in this example, doesn't need to be built with dynamic plugins nor is it required to release its source code. Instead, it only needs to provide an interface and the header file of that interface, and then scan those dynamic plugins at runtime so that they can be loaded.
Note
Dynamic plugins are commonly seen in complex applications, especially in commercial software such as Adobe Illustrator.
Similar to the static plugin we just wrote, we need to create a new Qt Plugin project and we'll call it EllipsePlugin
this time. Although you can write a new interface along with this plugin, here we will just focus on plugin-related topics. So, we just reuse the InsertInterface
class while the ellipseplugin.pro
...