Yes, I'm pasting the content of the plugin files
iconeditorplugin.cpp
#include <QtPlugin>
#include "../iconeditor/iconeditor.h"
#include "iconeditorplugin.h"
IconEditorPlugin
::IconEditorPlugin(QObject *parent
){
}
QString IconEditorPlugin
::name() const {
return "IconEditor";
}
QString IconEditorPlugin
::includeFile() const {
return "iconeditor.h";
}
QString IconEditorPlugin
::group() const {
return tr("Image Manipulation Widgets");
}
QIcon IconEditorPlugin
::icon() const {
return QIcon(":/images/iconeditor.png");
}
QString IconEditorPlugin
::toolTip() const {
return tr("An icon editor widget");
}
QString IconEditorPlugin
::whatsThis() const {
return tr("This widget is presented in Chapter 5 of <i>C++ GUI "
"Programming with Qt 4</i> as an example of a custom Qt "
"widget.");
}
bool IconEditorPlugin::isContainer() const
{
return false;
}
{
return new IconEditor(parent);
}
Q_EXPORT_PLUGIN2(iconeditorplugin, IconEditorPlugin)
#include <QtPlugin>
#include "../iconeditor/iconeditor.h"
#include "iconeditorplugin.h"
IconEditorPlugin::IconEditorPlugin(QObject *parent)
: QObject(parent)
{
}
QString IconEditorPlugin::name() const
{
return "IconEditor";
}
QString IconEditorPlugin::includeFile() const
{
return "iconeditor.h";
}
QString IconEditorPlugin::group() const
{
return tr("Image Manipulation Widgets");
}
QIcon IconEditorPlugin::icon() const
{
return QIcon(":/images/iconeditor.png");
}
QString IconEditorPlugin::toolTip() const
{
return tr("An icon editor widget");
}
QString IconEditorPlugin::whatsThis() const
{
return tr("This widget is presented in Chapter 5 of <i>C++ GUI "
"Programming with Qt 4</i> as an example of a custom Qt "
"widget.");
}
bool IconEditorPlugin::isContainer() const
{
return false;
}
QWidget *IconEditorPlugin::createWidget(QWidget *parent)
{
return new IconEditor(parent);
}
Q_EXPORT_PLUGIN2(iconeditorplugin, IconEditorPlugin)
To copy to clipboard, switch view to plain text mode
iconeditorplugin.h
#ifndef ICONEDITORPLUGIN_H
#define ICONEDITORPLUGIN_H
#include <QtDesigner/QDesignerCustomWidgetInterface>
class IconEditorPlugin
: public QObject,
{
Q_OBJECT
public:
IconEditorPlugin
(QObject *parent
= 0);
bool isContainer() const;
};
#endif
#ifndef ICONEDITORPLUGIN_H
#define ICONEDITORPLUGIN_H
#include <QtDesigner/QDesignerCustomWidgetInterface>
class IconEditorPlugin : public QObject,
public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
IconEditorPlugin(QObject *parent = 0);
QString name() const;
QString includeFile() const;
QString group() const;
QIcon icon() const;
QString toolTip() const;
QString whatsThis() const;
bool isContainer() const;
QWidget *createWidget(QWidget *parent);
};
#endif
To copy to clipboard, switch view to plain text mode
iconeditor.h
#ifndef ICONEDITOR_H
#define ICONEDITOR_H
#include <QColor>
#include <QImage>
#include <QWidget>
#include <QtDesigner/QDesignerExportWidget>
//QDESIGNER_WIDGET_EXPORT
class QDESIGNER_WIDGET_EXPORT IconEditor
: public QWidget{
Q_OBJECT
Q_PROPERTY(QColor penColor READ penColor WRITE setPenColor
) Q_PROPERTY(QImage iconImage READ iconImage WRITE setIconImage
) Q_PROPERTY(int zoomFactor READ zoomFactor WRITE setZoomFactor DESIGNABLE true)
public:
void setPenColor
(const QColor &newColor
);
QColor penColor
() const { return curColor;
} void setZoomFactor(int newZoom);
int zoomFactor() const { return zoom; }
void setIconImage
(const QImage &newImage
);
QImage iconImage
() const { return image;
}
protected:
private:
void setImagePixel
(const QPoint &pos,
bool opaque
);
QRect pixelRect
(int i,
int j
) const;
int zoom;
};
#endif
#ifndef ICONEDITOR_H
#define ICONEDITOR_H
#include <QColor>
#include <QImage>
#include <QWidget>
#include <QtDesigner/QDesignerExportWidget>
//QDESIGNER_WIDGET_EXPORT
class QDESIGNER_WIDGET_EXPORT IconEditor : public QWidget
{
Q_OBJECT
Q_PROPERTY(QColor penColor READ penColor WRITE setPenColor)
Q_PROPERTY(QImage iconImage READ iconImage WRITE setIconImage)
Q_PROPERTY(int zoomFactor READ zoomFactor WRITE setZoomFactor DESIGNABLE true)
public:
IconEditor(QWidget *parent = 0);
void setPenColor(const QColor &newColor);
QColor penColor() const { return curColor; }
void setZoomFactor(int newZoom);
int zoomFactor() const { return zoom; }
void setIconImage(const QImage &newImage);
QImage iconImage() const { return image; }
QSize sizeHint() const;
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void paintEvent(QPaintEvent *event);
private:
void setImagePixel(const QPoint &pos, bool opaque);
QRect pixelRect(int i, int j) const;
QColor curColor;
QImage image;
int zoom;
};
#endif
To copy to clipboard, switch view to plain text mode
iconeditor.cpp
#include <QtGui>
#include "iconeditor.h"
IconEditor
::IconEditor(QWidget *parent
){
...
}
void IconEditor
::setPenColor(const QColor &newColor
) {
curColor = newColor;
}
void IconEditor::setZoomFactor(int newZoom)
{
...
}
void IconEditor
::setIconImage(const QImage &newImage
) {
...
}
QSize IconEditor
::sizeHint() const {
...
return size;
}
{
...
}
{
...
}
{
...
}
void IconEditor
::setImagePixel(const QPoint &pos,
bool opaque
) {
... not relevant
}
QRect IconEditor
::pixelRect(int i,
int j
) const {
...
}
#include <QtGui>
#include "iconeditor.h"
IconEditor::IconEditor(QWidget *parent)
: QWidget(parent)
{
...
}
void IconEditor::setPenColor(const QColor &newColor)
{
curColor = newColor;
}
void IconEditor::setZoomFactor(int newZoom)
{
...
}
void IconEditor::setIconImage(const QImage &newImage)
{
...
}
QSize IconEditor::sizeHint() const
{
...
return size;
}
void IconEditor::mousePressEvent(QMouseEvent *event)
{
...
}
void IconEditor::mouseMoveEvent(QMouseEvent *event)
{
...
}
void IconEditor::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
...
}
void IconEditor::setImagePixel(const QPoint &pos, bool opaque)
{
... not relevant
}
QRect IconEditor::pixelRect(int i, int j) const
{
...
}
To copy to clipboard, switch view to plain text mode
iconeditorplugin.pro
TEMPLATE = lib
CONFIG += designer plugin release
HEADERS = ../iconeditor/iconeditor.h \
iconeditorplugin.h
SOURCES = ../iconeditor/iconeditor.cpp \
iconeditorplugin.cpp
RESOURCES = iconeditorplugin.qrc
DESTDIR = $$[QT_INSTALL_PLUGINS]/designer
target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target
TEMPLATE = lib
CONFIG += designer plugin release
HEADERS = ../iconeditor/iconeditor.h \
iconeditorplugin.h
SOURCES = ../iconeditor/iconeditor.cpp \
iconeditorplugin.cpp
RESOURCES = iconeditorplugin.qrc
DESTDIR = $$[QT_INSTALL_PLUGINS]/designer
target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target
To copy to clipboard, switch view to plain text mode
And resources are okay in a qrc file. Why the plugin still can't load?
Bookmarks