Use classes from a plugin inQT



  • Hello everyone,
    I am preety new to QT and of course plugins.
    I have a plugin called DatabaseManager that looks like this:
    @
    class DatabaseManagerInterface
    {
    public:
    ~DatabaseManagerInterface() {}
    virtual bool openDB() = 0;
    virtual void closeDB() = 0;
    virtual QString lastError() = 0;
    };

    QT_BEGIN_NAMESPACE
    Q_DECLARE_INTERFACE(DatabaseManagerInterface,"ro.jkoder.DatabaseManager/1.0")
    QT_END_NAMESPACE
    @

    Now , in this plugin i have some more classes, for example: ClientManager. From within the plugin, i can access the class without a problem, BUT how can i make this class wisible to the application so that i can do something like:

    NOTE: this is on my main application
    @
    QObject* plugin = pluginManager.getPlugin(DATABASE_MANAGER_PLUGIN);
    if (plugin) {
    databaseManager = qobject_cast<DatabaseManagerInterface *>(plugin);
    }
    //! HOW CAN I USE THIS IN MY MAIN APPLICATION ???
    ClientManager cmanager = databasemanager->getClientManager()
    @

    I am strugling for 2 days now without a result.
    Can anyone please help me a little bit ?



  • There are more the one way a library can get published to the users.
    If you have a .lib file and a .h file include the .h file and your able to use all classes defined in the header file.
    What usually is a good way to avoid the problems of recursive included is forward declarations, but then you are only able to use pointers to classes.
    Hope this will give you some more ideas.
    Maybe some more information about the plugin might help. What kind of files do you have?
    Greetz


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.