I want to add my customed widget to designer,but it doesn't work!
It said that in the function QWidget * NeonLightPlugin::createWidget(QWidget * parent) cannot convert 'NeonLightPlugin*' to 'Widget*'.
And it also said error: expected constructor, destructor, or type conversion before '(' token in the last line Q_EXPORT_PLUGIN2(NeonLight, NeonLightPlugin)!!!
What is wrong with it???
Thanks very much!
The plugin files are here:
neonlightplugin.h
#ifndef NEONLIGHTPLUGIN_H
#define NEONLIGHTPLUGIN_H
#include <QObject>
#include <QIcon>
#include <QWidget>
#include <QString>
#include <QDesignerCustomWidgetInterface>
{
Q_OBJECT
public:
NeonLightPlugin
(QObject * parent
= 0);
bool isContainer() const;
};
#endif // NEONLIGHTPLUGIN_H
#ifndef NEONLIGHTPLUGIN_H
#define NEONLIGHTPLUGIN_H
#include <QObject>
#include <QIcon>
#include <QWidget>
#include <QString>
#include <QDesignerCustomWidgetInterface>
class NeonLightPlugin:public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
NeonLightPlugin(QObject * parent = 0);
bool isContainer() const;
QIcon icon() const;
QString group() const;
QString includeFile() const;
QString name() const;
QString toolTip() const;
QString whatsThis() const;
QWidget *createWidget(QWidget *parent);
};
#endif // NEONLIGHTPLUGIN_H
To copy to clipboard, switch view to plain text mode
And the neonlightplugin.cpp
#include <QWidget>
#include "neonlightplugin.h"
NeonLightPlugin
::NeonLightPlugin(QObject *parent
){
}
QString NeonLightPlugin
::name() const {
return "NeonLight";
}
QString NeonLightPlugin
::includeFile() const {
return "neonlight.h";
}
QString NeonLightPlugin
::group() const {
return tr("Special Effect");
}
QIcon NeonLightPlugin
::icon() const {
return QIcon(":/file/resources/light.png");
}
QString NeonLightPlugin
::toolTip() const {
return tr("A neon light widget for special effect");
}
QString NeonLightPlugin
::whatsThis()const {
return tr("This widget is presented by Tan Le");
}
bool NeonLightPlugin::isContainer() const
{
return false;
}
{
return new NeonLightPlugin(parent);
}
Q_EXPORT_PLUGIN2(NeonLight, NeonLightPlugin)
#include <QWidget>
#include "neonlightplugin.h"
NeonLightPlugin::NeonLightPlugin(QObject *parent)
{
}
QString NeonLightPlugin::name() const
{
return "NeonLight";
}
QString NeonLightPlugin::includeFile() const
{
return "neonlight.h";
}
QString NeonLightPlugin::group() const
{
return tr("Special Effect");
}
QIcon NeonLightPlugin::icon() const
{
return QIcon(":/file/resources/light.png");
}
QString NeonLightPlugin::toolTip() const
{
return tr("A neon light widget for special effect");
}
QString NeonLightPlugin::whatsThis()const
{
return tr("This widget is presented by Tan Le");
}
bool NeonLightPlugin::isContainer() const
{
return false;
}
QWidget * NeonLightPlugin::createWidget(QWidget * parent)
{
return new NeonLightPlugin(parent);
}
Q_EXPORT_PLUGIN2(NeonLight, NeonLightPlugin)
To copy to clipboard, switch view to plain text mode
Bookmarks