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
Asked
Active
Viewed 5,710 times
1

Dravigon
- 73
- 1
- 8
-
The plugin needs to be in the list of plugin paths (see `QQmlEngine::addPluginPath`) and you simply import it and use it. – dtech Mar 11 '17 at 20:01
-
can you give a example?? – Dravigon Mar 11 '17 at 22:55
1 Answers
3
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 producelibMyAppTypes.so
on Linux andMyAppTypes.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 withQQmlEngine::pluginPathList()
and modified usingQQmlEngine::addPluginPath()
.
-
again i don't get it i have he compiled plugin in a path say /QMLTermWidget in my main programs how should i add it to my main program – Dravigon Mar 11 '17 at 22:36
-
i have added the plugin folder to the qrc like [this question](http://stackoverflow.com/questions/31726321/load-qmldir-from-qrc-file?noredirect=1&lq=1) but the suggested answer does not work – Dravigon Mar 13 '17 at 16:18