Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Use classes from a plugin inQT

Use classes from a plugin inQT

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 959 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JKoder
    wrote on last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      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

      Greetz, Jeroen

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved