Zavulon
Zavulon

Reputation: 141

Q_DECLARE_INTERFACE for plugin creation throws errors all over

Environment:

I want to develop an application that can be expanded through plug-ins. Therefore I created a standard library project where I want to define the plug-in interfaces. This library should then be consumed by the main application and its plug-ins.

I read about the Qt plug-in system on the official websites and sought help by duckduckgo-ing, but I'm stuck with these following errors:

This is the code:

#ifndef VCCPLUGIN_H
#define VCCPLUGIN_H

#include "VccPluginInterface_global.h"

class VCCPLUGININTERFACE_EXPORT VccPlugin
{
public:
    VccPlugin();
    ~VccPlugin();
    void DoeEenTwuk();
};

#define VccPlugin_iid "automation.general.vcc.interface"

Q_DECLARE_INTERFACE(VccPlugin, VccPlugin_iid);

#endif // VCCPLUGIN_H

Also note, I have little experience in both C++ and Qt.

Any help very appreciated, thanks

Upvotes: 0

Views: 293

Answers (1)

Zavulon
Zavulon

Reputation: 141

I have found the issue. The problem is that the compiler couldn't find the macro, so all I had to add was:

#include <QtPlugin>

Since Q_DECLARE_INTERFACE is defined in QtPlugin. Your example didn't import QtPlugin but was probably imported implicit by another import, probably QMainWindow.

It would have been simpler if I got an error like: "Could not find symbol Q_DECLARE_INTERFACE" if you ask me. Especially since I'm rather blue in this topic.

Thanks for your support @NgocMinhNguyen and others

Upvotes: 1

Related Questions