Why can Qt Creator use QPluginLoader to load plugins?
I'm new to qt,forgive me if this is a stupid question.
I checked the qt creator source code.And noticed that in the libs/extensionsystem/pluginspec.cpp, it use QPluginLoader to load the dll file.The plugins are subclasses of IPlugin.
I also read the help/tutorial,isn't that we have to use some macros like,Q_EXPORT_PLUGIN2(),Q_INTERFACES() if we want to create application plugins?And if we don't use these macros,the QPluginLoader won't load the dll file,right?
So,in the qtcreator,how does the PluginSpec class enable to load the plugin dll files with QPluginLoader?:confused:
Re: Why can Qt Creator use QPluginLoader to load plugins?
Q_INTERFACES and Q_DECLARE_INTERFACE enable qobject_cast to interface, ie IFace * face = qobject_cast<IFace *>(pluginClass);
If pluginClass inherits QObject, these macroses are not needed.
But Q_EXPORT_PLUGIN2 or Q_EXPORT_PLUGIN creates functions that are exported from plugin - these functions create instance of your exported class. Yes, without one of them plugin won't work.
Re: Why can Qt Creator use QPluginLoader to load plugins?
But qt creator didn't use these macros...lol
Re: Why can Qt Creator use QPluginLoader to load plugins?
in qtcreator all interfaces are subclasses of QObject - they don't need first macro
and second is used: file src/plugins/bineditor/bineditorplugin.cpp
Code:
Q_EXPORT_PLUGIN(BinEditorPlugin)
Re: Why can Qt Creator use QPluginLoader to load plugins?
OK,I miss that part,Thanks for pointing that out.I'll check for that..:)