Plugins for Qt (e.g. designer, iconengines, image formats) are automatically discovered and loaded by Qt based on the directory plugins are into. There are multiple ways to tell Qt where to scan directories containing plugins.
addLibraryPath would probably be the easiest, but because plugins (e.g. designer) must be localized by Qt Designer when designing UIs, the solution is to have the environment variable
QT_PLUGIN_PATH set by the Slicer launcher (or using a qt.conf file when no launcher is available (e.g. MacOsX Slicer installs)).
A limitation of qt.conf is that it only handles 1 plugin path, this is why Slicer installs must have their plugins in a unique top directory.
To create a plugin, use one of the macros in ctkMacroBuildQtPlugin.cmake:
ctkMacroBuildQtDesignerPluginto build a Qt Designer plugin.
ctkMacroBuildQtIconEnginesPluginto build an Icon Engine plugin.
They are built in the bin/PLUGIN_TYPE directory where PLUGIN_TYPE is designer, imageformats... Only on Visual Studio they are also automatically in XXX-build/bin/PLUGIN_TYPE/BUILD_TYPE where BUILD_TYPE is Debug, Release... Refer to
Because Qt plugins are not direct dependency of Slicer (discovered and dynamically loaded at run time), Qt plugins need to be compiled as MODULE and need to be manually bundled at package time (see SlicerCompleteBundles.cmake.in).
QT_PLUGIN_PATH must points to 2 paths: Slicer-Superbuild/CTK-build/CTK-build/bin and
The default Qt plugins (such as svg image format or sqldriver plugins) are in the Qtdir plugin path.
Plugins locations for Slicer builds:
On Windows, they also are in the following paths but are ignored by Qt:
QT_PLUGIN_PATH points to a unique path:
Slicer_INSTALL_QtPlugins_DIR=Slicer/lib/QtPlugins. However, on MacOSX, there is no launcher, so environment variables can't be set prior to launching Slicer. A qt.conf containing the Slicer/lib/QtPlugins path is used for the mac bundle.
In order for the plugins to be installed at the right location,
CTK_INSTALL_QTPLUGIN_DIR must be passed to CTK (see External_CTK.cmake, this is internally used by ctkMacroBuildQtPlugin.cmake)
Because Qt is packaged within Slicer, the plugins must also be packaged (see SlicerBlockInstallQtPlugins.cmake)
Plugins locations for installed Slicer:
Extensions need to provide their plugin paths to the Slicer launcher.
|Page under construction.|