[Qt-creator] Get access to any plugin of QtC

Ziller Eike Eike.Ziller at theqtcompany.com
Tue Feb 3 12:15:11 CET 2015


> On Feb 3, 2015, at 11:09 AM, Андрей Полтавец <andrey.poltavets at gmail.com> wrote:
> 
> Hello.
> Sorry for newbie question, I don't know - can I ask questions like this here?
> 
> I want to know what should I invoke for getting access to any active plugin of OtC? Correct please me if I am wrong - plugins are origined from QObject objects, right? So, where this interface from what I can execute public functions of plugins?
> 
> For example, for plugin "ProjectExplorer" my searches led me here:
> (ExtensionSystem::PluginManager::getObjectByClassName("ProjectExplorerPlugin"))->some_public_function??

Normally plugins do not get added to the plugin manager’s “object pool”, so you’ll not find most other plugins through this method.
You can use ExtensionSystem::PluginManager::plugins(), get the plugin spec that you want, and spec->plugin() for the IPlugin instance.

> output:
> /home/drew/LPROJ/LPROJ-main/src/libprojplugin.cpp:71: error: 'class QObject' has no member named 'projectFilePatterns'
>      qDebug() << (ExtensionSystem::PluginManager::getObjectByClassName("ProjectExplorerPlugin"))->projectFilePatterns();
>                                                                                                   ^
> 
> Where is my mistake?

The object that is returned by getObjectByClassName is of type QObject, which does not have a “projectFilePatterns()” method.
You would need to cast that QObject to a ProjectExplorerPlugin instance first, or, since you then have to link against project explorer plugin directly anyhow, just use
#include <projectexplorer/projectexplorer.h>
...
ProjectExplorer::ProjectExplorer::projectFilePatterns()

Br, Eike

-- 
Eike Ziller, Senior Software Engineer - The Qt Company GmbH
 
The Qt Company GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B



More information about the Qt-creator mailing list