1
votes

Can any one say the step by step method to incorporate already created plugins into a new QML based program.
I've got this plugin called qmltermwidget from git qmltermwidget github
Now i have compiled it and I can test the example program in it but I don't know how to use it in my custom application using Qt/QML

1
The plugin needs to be in the list of plugin paths (see QQmlEngine::addPluginPath) and you simply import it and use it. - dtech
can you give a example?? - dravigon

1 Answers

3
votes

See "Creating C++ Plugins for QML".
In your case, you already have a plugin (from your previous question), but the steps involve:

  • Write a project file for the plugin
  • Create a qmldir file to describe the plugin

QML extension plugins are for either application-specific or library-like plugins.
Library plugins should limit themselves to registering types, as any manipulation of the engine's root context may cause conflicts or other issues in the library user's code.

The "Module Definition qmldir Files" is where you declare a plugin to be made available by the module.

plugin <Name> [<Path>]
  • <Name> is the plugin library name. This is usually not the same as the file name of the plugin binary, which is platform dependent; e.g. the library MyAppTypes would produce libMyAppTypes.so on Linux and MyAppTypes.dll on Windows.
  • <Path> (optional) specifies either:
    • an absolute path to the directory containing the plugin file, or
    • a relative path from the directory containing the qmldir file to the directory containing the plugin file.

By default the engine searches for the plugin library in the directory that contains the qmldir file.
The plugin search path can be queried with QQmlEngine::pluginPathList() and modified using QQmlEngine::addPluginPath().