[Interest] Doubt extending my app functions ability
bhood2 at comcast.net
Thu Jan 12 21:29:14 CET 2017
On 1/12/2017 6:23 AM, Ernesto wrote:
> Hello to everyone,
> My name is Ernesto. I am a beginner in Qt programming and I have an
> specifics problems whit my first big project (desktop app). Let me explain
> I have to include plugins or add-ons to my application for new file format
> types; I looked around QPluginLoader class, Dynamic and Static libraries
> classes to achieve this goal, and here is my problem, in each one of this I
> have to include the header file and the library (or plugins) in my project.
> I have to develop other mini app to create those plugins or libraries. So
> here is _my first problem_, I don´t know how many plugins or libraries will
> be development to include in my app.
I will not address your entire problem (because I'm not clearly understanding
the second one), but your first is easy enough to answer. The answer is: You
don't /need/do know how many plug-ins will be in development.
Plug-ins, by definition, are external code to your main application. You
application needs to /discover/those pieces of external code when it runs.
This way, any number of plug-ins can be included with your application--or
even added later by the user to an existing installation of your
application--without having to modify any of your main application's code.
For example, when your main application starts, it looks in a location--either
hard-coded, or defined by the user--and discovers all the available shared
QStringList plugins_list = plugins.entryList(QStringList() << "*.dll" <<
With each shared library it finds, it tests each to see if it is a plug-in
designed for your application by coercing it to the interface contract,
foreach(const QString& filename, plugins_list)
QString plugin_path =
QObject* instance = plugin.instance();
IErnestoPlugin* iernestofactory =
Each one that supports the contract of your interface ("IErnestoPlugin") can
be safely used within your application as a plug-in designed for your main
I hope I understood the first problem correctly. Apologies if I didn't.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest