Re: Creating custom plugin
Ehm, where is Q_DECLARE_INTERFACE?
Re: Creating custom plugin
Oh, I forgot to add this. To be sure - this time its entire interface header.
Code:
#ifndef _CCS_SHOP_INTERFACE_INCLUDE_
#define _CCS_SHOP_INTERFACE_INCLUDE_
#include <QtCore/QStringList>
#include <QtGui/QIcon>
class ShopInterface
{
public:
virtual ~ShopInterface() {}
virtual QIcon getShopIcon
() const = 0;
virtual bool checkPrices
(QString strCompName,
double & dPrice,
QString strURL
);
};
Q_DECLARE_INTERFACE(ShopInterface, "ShopInterface/1.0");
#endif //_CCS_SHOP_INTERFACE_INCLUDE_
And - of course - in implemented plugin there is correct #include.
Re: Creating custom plugin
Does the plugin have the Q_EXPORT_PLUGIN2 macro?
Re: Creating custom plugin
Yes, but placed in cpp file. In plugin examples I see that all of them have this macro there.
On the other hand - it looks like MOC compiler tries to expand Q_INTERFACES define and have problem to find appropriate interface definitions.
Re: Creating custom plugin
Did you include the file containing the interface definition in the plugin header file?
Re: Creating custom plugin
Code:
#ifndef _CCS_SHOP_1_INCLUDE_
#define _CCS_SHOP_1_INCLUDE_
#include <ShopInterface.h>
#include <QtCore/QtPlugin>
class Shop1Plugin
: public QObject,
public ShopInterface
{
Q_OBJECT
Q_INTERFACES(ShopInterface)
public:
virtual ~Shop1Plugin ();
virtual QIcon getShopIcon
() const;
virtual bool checkPrices
(QString strCompName,
double & dPrice,
QString strURL
);
};
#endif
It seems most likely that #include isn't processed. Like MOC can't finding Q_DECLARE_INTERFACE, but as you see - its there. I'll make test and put entire interface in one file with its realization.
PS. And it worked. If Interface is in the same file as its realization - it worked. Why MOC can't find this include? Maybe I should add this include to MOC processing line.
Re: Creating custom plugin
Make sure the directory containing ShopInterface.h is in INCLUDEPATH.
Re: Creating custom plugin
I use CMake to create configurations and projects. And this is the first time that MOC requires includes. Now I now what need to be fixed.
Re: Creating custom plugin
Quote:
Originally Posted by
wysota
Make sure the directory containing ShopInterface.h is in INCLUDEPATH.
thanks really a great tip because in previous projects from me cmake always seached all header files automatically.
I had the same problem but it is fixed now.