Question

I have a custom QT plugin module that has embedded resources. I want to statically link this plugin with an application:

LIBS += -lstatic_plugin_with_resources

In the application I am using the Q_IMPORT_PLUGIN() macro, which allows the application to use the plugin; however the plugin can not access its embedded resources.

Using the plugin as a shared library does work.

Was it helpful?

Solution

It is possible. In the application you need to explicitly initialize the resources that are contained in the static plugin.

This is accomplished by calling the Q_INIT_RESOURCE(resource_base_name), where resource_base_name is the base name of the .qrc file that specifies the resources. This should probably be called in main() or at application startup. Optionally you can call Q_CLEANUP_RESOURCE() if the plugin is no longer being used.

See the last section of the QT 4.5 resource doc. Also see the documentation for Q_INIT_RESOURCE.

This worked for me on the linux version of QT 4.5.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top