Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:27:00+00:00 2026-05-29T06:27:00+00:00

I want to make an application with plugins that also can have plugins (which

  • 0

I want to make an application with plugins that also can have plugins (which the main application do not need to know about). Reason is that I want to make a general IDE for some code projects, then I make a image handler plugin. I would then like the image handler plugin to have some filter plugins of its own that the main application do not need to know about. Is this possible?

Here is what I got my self:

I would like to make a main IDE that have some interfaces.

class IDocumentFactory
{
public:
    virtual ~IDocumentFactory() {}

     //virtual QStringList documents() const = 0;
     virtual QVector<FileOpenEntries>   name_filters() const = 0;
     virtual QWidget* open_document( QWidget* parent,
                                     const QStringList &filepaths,
                                     const QString &name_filter_key) const = 0;

};
Q_DECLARE_INTERFACE(IDocumentFactory,       "S-DAIDE.IDocumentFactory/1.0")
class IDeclarePlugins
{
public:
    virtual ~IDeclarePlugins() {}

    virtual QStringList plugins() const = 0;
    virtual void load_plugings(QObject * plugins) = 0;
};
Q_DECLARE_INTERFACE(IDeclarePlugins,        "S-DAIDE.IDeclarePlugins/1.0")

Now I would like to define an interface in my plugin that other plugins can implement.

class MyPlugin : public QObject, IDeclarePlugins
{
    Q_OBJECT
    Q_INTERFACES(IDeclarePlugins)

    ...
    QStringList ImagePlugin::plugins() const
    {
    return QStringList() << "S-DAIDE.ImagePlugin.IOverlay/1.0";
    }
}

In my main app loading plugins.

foreach (QString fileName, m_plugins_dir.entryList(QDir::Files)) {

         QPluginLoader loader(m_plugins_dir.absoluteFilePath(fileName));
         QObject *plugin = loader.instance();

}

Do there exist a way to check if a plugin implements an interface based on the string used with Q_DECLARE_INTERFACE. Such I can make the plugin load all other plugins that it declare by the virtual QStringList plugins() const = 0;

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:27:01+00:00Added an answer on May 29, 2026 at 6:27 am

    By design, you should qobject_cast to interface classes, but not to use those ids.

    You can still create a function QString id() that will return your id for every plugin, you can check that function result in your loader code.

    You can check, if your plugin has given id, as you want, in principle, you can find the way to do it in Q_DECLARE_INTERFACE macro defenition.

    bool isIdMatch = const_cast<QObject *>(object)->qt_metacast(IId) != 0;
    

    But qt_metacast is not documented, so I do not recommend you to use this method.

    If you want get rid of repeatedly writing ids 2 times, you can use macros, that Qt’s framework so love itself:

    #define DECLARE_ID(__iid) \
        virtual QString id() const {return iid_private();}\
        static const char* const iid_private() {return __iid;}
    
    #define GET_ID(IFace) IFace::iid_private()
    
    class IFace
    {
    public:
        DECLARE_ID("Iface")
    };
    Q_DECLARE_INTERFACE(IFace, GET_ID(IFace))
    
    class IFace2: public IFace
    {
    public:
        DECLARE_ID("Iface2")
    };
    Q_DECLARE_INTERFACE(IFace2,GET_ID(IFace2))
    
    
    int main(int c, char**v)
    {
        IFace* f = new IFace2();
        qDebug() << f->id() << f->iid_private();
        qDebug() << GET_ID(IFace) <<GET_ID(IFace2);
        return 0;//a.exec();
    }
    

    Study the output and note, that you should use id() function instead of iid_private

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make an application in C or C++ which have to monitor
I want to make a JavaScript application that's not open source, and thus I
I want to make an console application of c which can run other applications
I want to make an Application that uses RxTx version 2.2pre2 to work with
Okay so I want to make an application that launches other applications. However, the
I want to make an android application that shows a listing of applications (downloaded
I have a class that implements a plugin for an existing application. I also
I want to make my application to run other people's code, aka plugins. However,
I have a relatively simple goal: I want to create a Cocoa application which
I have this web application that has grown to an unmanageable mess. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.