I have created a custom widget and a plugin for that widget in Designer. I have tested the custom widget localy and it works fine. The widget appears in the widget box in designer/form editor and I can drag i it to my window hand handle the signals & and slots. But when I hit preview or compile the widget doesn´t show. I do not get any error messages and when i look into the generated ui_XXXXX.h and it looks fine. What am I missing? Could Upload All code......
customDial.proj
CONFIG += designer \
plugin \
debug_and_release
TARGET = $$qtLibraryTarget(speeddialplugin)
TEMPLATE = lib
HEADERS = speeddialplugin.h \
qtsvgdialgauge.h \
qtsvgpixmapcache.h
SOURCES = speeddialplugin.cpp \
qtsvgdialgauge.cpp \
qtsvgpixmapcache.cpp
RESOURCES = icons.qrc \
skins.qrc
LIBS += -L.
target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
# include(speeddial.pri)
QT += svg
CONFIG += designer \
plugin \
debug_and_release
TARGET = $$qtLibraryTarget(speeddialplugin)
TEMPLATE = lib
HEADERS = speeddialplugin.h \
qtsvgdialgauge.h \
qtsvgpixmapcache.h
SOURCES = speeddialplugin.cpp \
qtsvgdialgauge.cpp \
qtsvgpixmapcache.cpp
RESOURCES = icons.qrc \
skins.qrc
LIBS += -L.
target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
# include(speeddial.pri)
QT += svg
To copy to clipboard, switch view to plain text mode
speedDialPlugin.h
#ifndef SPEEDDIALPLUGIN_H
#define SPEEDDIALPLUGIN_H
#include <QtDesigner/QDesignerCustomWidgetInterface>
#include <QObject>
#include <Qt>
{
Q_OBJECT
public:
speedDialPlugin
(QObject *parent
= 0);
bool isContainer() const;
bool isInitialized() const;
private:
bool m_initialized;
};
#endif
#ifndef SPEEDDIALPLUGIN_H
#define SPEEDDIALPLUGIN_H
#include <QtDesigner/QDesignerCustomWidgetInterface>
#include <QObject>
#include <Qt>
class speedDialPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
speedDialPlugin(QObject *parent = 0);
bool isContainer() const;
bool isInitialized() const;
QIcon icon() const;
QString domXml() const;
QString group() const;
QString includeFile() const;
QString name() const;
QString toolTip() const;
QString whatsThis() const;
QWidget *createWidget(QWidget *parent);
void initialize(QDesignerFormEditorInterface *core);
private:
bool m_initialized;
};
#endif
To copy to clipboard, switch view to plain text mode
speedDialPlugin.cpp
#include "qtsvgdialgauge.h"
#include "speeddialplugin.h"
#include <QtCore/QtPlugin>
speedDialPlugin
::speedDialPlugin(QObject *parent
){
m_initialized = false;
}
{
if (m_initialized)
return;
// Add extension registrations, etc. here
m_initialized = true;
}
bool speedDialPlugin::isInitialized() const
{
return m_initialized;
}
{
//return new speedDial(parent);
QtSvgDialGauge * gauge = new QtSvgDialGauge(parent);
gauge->setSkin("Tachometer");
gauge->setMinimum(0);
gauge->setMaximum(120);
gauge->setValue(0);
return gauge;
}
QString speedDialPlugin
::name() const {
}
QString speedDialPlugin
::group() const {
}
QIcon speedDialPlugin
::icon() const {
}
QString speedDialPlugin
::toolTip() const {
}
QString speedDialPlugin
::whatsThis() const {
}
bool speedDialPlugin::isContainer() const
{
return false;
}
QString speedDialPlugin
::domXml() const {
return QLatin1String("<widget class=\"speedDial\" name=\"speedDial\">\n</widget>\n");
}
QString speedDialPlugin
::includeFile() const {
}
Q_EXPORT_PLUGIN2(speeddialplugin, speedDialPlugin)
#include "qtsvgdialgauge.h"
#include "speeddialplugin.h"
#include <QtCore/QtPlugin>
speedDialPlugin::speedDialPlugin(QObject *parent)
: QObject(parent)
{
m_initialized = false;
}
void speedDialPlugin::initialize(QDesignerFormEditorInterface * /* core */)
{
if (m_initialized)
return;
// Add extension registrations, etc. here
m_initialized = true;
}
bool speedDialPlugin::isInitialized() const
{
return m_initialized;
}
QWidget *speedDialPlugin::createWidget(QWidget *parent)
{
//return new speedDial(parent);
QtSvgDialGauge * gauge = new QtSvgDialGauge(parent);
gauge->setSkin("Tachometer");
gauge->setMinimum(0);
gauge->setMaximum(120);
gauge->setValue(0);
return gauge;
}
QString speedDialPlugin::name() const
{
return QLatin1String("speedDial");
}
QString speedDialPlugin::group() const
{
return QLatin1String("");
}
QIcon speedDialPlugin::icon() const
{
return QIcon();
}
QString speedDialPlugin::toolTip() const
{
return QLatin1String("");
}
QString speedDialPlugin::whatsThis() const
{
return QLatin1String("");
}
bool speedDialPlugin::isContainer() const
{
return false;
}
QString speedDialPlugin::domXml() const
{
return QLatin1String("<widget class=\"speedDial\" name=\"speedDial\">\n</widget>\n");
}
QString speedDialPlugin::includeFile() const
{
return QLatin1String("hh.h");
}
Q_EXPORT_PLUGIN2(speeddialplugin, speedDialPlugin)
To copy to clipboard, switch view to plain text mode
qtSvgDialGauge.h
/*
*/
#ifndef QT_SVG_DIAL_GAUGE
#define QT_SVG_DIAL_GAUGE
#include <QtGui/QWidget>
#include <Qt>
#include <QtCore/QPair>
#include <QtDesigner/QDesignerExportWidget>
class QtSvgPixmapCache;
class QDESIGNER_WIDGET_EXPORT QtSvgDialGauge
: public QWidget{
Q_OBJECT
Q_PROPERTY(QString skin READ skin WRITE setSkin
) Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
Q_PROPERTY(qreal startAngle READ startAngle WRITE setStartAngle)
Q_PROPERTY(qreal endAngle READ endAngle WRITE setEndAngle)
public:
explicit QtSvgDialGauge
(QWidget * parent
= 0);
~QtSvgDialGauge();
void setSkin(const QString& skin);
void setMinimum(int minimum);
void setMaximum(int maximum);
void setNeedleOrigin(qreal x, qreal y);
void setStartAngle(qreal angle);
void setEndAngle(qreal angle);
int value() const;
int minimum() const;
int maximum() const;
qreal needleOriginX() const;
qreal needleOriginY() const;
qreal startAngle() const;
qreal endAngle() const;
virtual QSize minimumSizeHint
() const;
virtual QSize sizeHint
() const;
void setShowOverlay(bool);
public slots:
void setValue(int value);
private:
void init();
QRectF availableRect
(QtSvgPixmapCache
* renderObject
) const;
QtSvgPixmapCache* m_backgroundRenderer;
QtSvgPixmapCache* m_needleShadowRenderer;
QtSvgPixmapCache* m_overlayRenderer;
/** minimum possible value **/
int m_minimum;
/** maximum possible value **/
int m_maximum;
/** actual value **/
int m_value;
/** smallest start angle **/
qreal m_startAngle;
/** highest end angle **/
qreal m_endAngle;
/** position x of needle **/
qreal m_originX;
/** position y of needle **/
qreal m_originY;
bool m_showOverlay;
/** name of actual skin **/
protected:
};
#endif // QT_SVG_DIAL_GAUGE
/*
*/
#ifndef QT_SVG_DIAL_GAUGE
#define QT_SVG_DIAL_GAUGE
#include <QtGui/QWidget>
#include <Qt>
#include <QtCore/QPair>
#include <QtDesigner/QDesignerExportWidget>
class QSvgRenderer;
class QtSvgPixmapCache;
class QDESIGNER_WIDGET_EXPORT QtSvgDialGauge : public QWidget
{
Q_OBJECT
Q_PROPERTY(QString skin READ skin WRITE setSkin)
Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
Q_PROPERTY(qreal startAngle READ startAngle WRITE setStartAngle)
Q_PROPERTY(qreal endAngle READ endAngle WRITE setEndAngle)
public:
explicit QtSvgDialGauge(QWidget * parent = 0);
~QtSvgDialGauge();
void setSkin(const QString& skin);
QString skin() const;
void setMinimum(int minimum);
void setMaximum(int maximum);
void setNeedleOrigin(qreal x, qreal y);
void setStartAngle(qreal angle);
void setEndAngle(qreal angle);
int value() const;
int minimum() const;
int maximum() const;
qreal needleOriginX() const;
qreal needleOriginY() const;
qreal startAngle() const;
qreal endAngle() const;
virtual QSize minimumSizeHint() const;
virtual QSize sizeHint() const;
void setShowOverlay(bool);
public slots:
void setValue(int value);
private:
void init();
QRectF availableRect(QtSvgPixmapCache * renderObject) const;
QtSvgPixmapCache* m_backgroundRenderer;
QtSvgPixmapCache* m_needleShadowRenderer;
QSvgRenderer* m_needleRenderer;
QRectF availableRect(QSvgRenderer * renderObject) const;
QtSvgPixmapCache* m_overlayRenderer;
/** minimum possible value **/
int m_minimum;
/** maximum possible value **/
int m_maximum;
/** actual value **/
int m_value;
/** smallest start angle **/
qreal m_startAngle;
/** highest end angle **/
qreal m_endAngle;
/** position x of needle **/
qreal m_originX;
/** position y of needle **/
qreal m_originY;
bool m_showOverlay;
/** name of actual skin **/
QString m_skin;
protected:
void paintEvent(QPaintEvent * event);
};
#endif // QT_SVG_DIAL_GAUGE
To copy to clipboard, switch view to plain text mode
qtSvgDialGauge.cpp
/*
*/
#include <QtGui/QPainter>
#include <QtSvg/QSvgRenderer>
#include "qtsvgdialgauge.h"
#include "qtsvgpixmapcache.h"
/*!
\class QtSvgDialGauge qtsvgdialgauge.h
\code
// Create a QtSvgDialGauge
QWidget * widget = new QWidget(this)
QtSvgDialGauge * gauge = new QtSvgDialGauge(widget);
gauge->setSkin("Beryl");
widget->addWidget(gauge);
widget->show();
\endcode
/*!
Constructor of the widget with \p parent as
Parent.
*/
QtSvgDialGauge
::QtSvgDialGauge(QWidget * parent
) m_minimum(0),
m_maximum(100),
m_value(0),
m_startAngle(0),
m_endAngle(100),
m_originX(0.5),
m_originY(0.5),
m_showOverlay(true)
{
init();
}
/*!
Destructor
*/
QtSvgDialGauge::~QtSvgDialGauge()
{
}
/*.....
......
.....
.....
.....
.....*/
}
/*
*/
#include <QtGui/QPainter>
#include <QtSvg/QSvgRenderer>
#include "qtsvgdialgauge.h"
#include "qtsvgpixmapcache.h"
/*!
\class QtSvgDialGauge qtsvgdialgauge.h
\code
// Create a QtSvgDialGauge
QWidget * widget = new QWidget(this)
QtSvgDialGauge * gauge = new QtSvgDialGauge(widget);
gauge->setSkin("Beryl");
widget->addWidget(gauge);
widget->show();
\endcode
/*!
Constructor of the widget with \p parent as
Parent.
*/
QtSvgDialGauge::QtSvgDialGauge(QWidget * parent)
: QWidget(parent),
m_minimum(0),
m_maximum(100),
m_value(0),
m_startAngle(0),
m_endAngle(100),
m_originX(0.5),
m_originY(0.5),
m_showOverlay(true)
{
init();
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
}
/*!
Destructor
*/
QtSvgDialGauge::~QtSvgDialGauge()
{
}
/*.....
......
.....
.....
.....
.....*/
}
To copy to clipboard, switch view to plain text mode
qtSvgPixmapCache.h
/*
*/
#ifndef QT_SVG_PIXMAP_CACHE
#define QT_SVG_PIXMAP_CACHE
#include <QtCore/QSizeF>
#include <Qt>
#include <QObject>
#include <QtDesigner/QDesignerExportWidget>
class QtSvgPixmapCachePrivate;
class QDESIGNER_WIDGET_EXPORT QtSvgPixmapCache
: public QObject{
Q_OBJECT
public:
QtSvgPixmapCache
(QObject* parent
= NULL);
#endif // QT_SVG_PIXMAP_CACHE
/*
*/
#ifndef QT_SVG_PIXMAP_CACHE
#define QT_SVG_PIXMAP_CACHE
#include <QtCore/QSizeF>
#include <Qt>
#include <QObject>
#include <QtDesigner/QDesignerExportWidget>
class QPainter;
class QString;
class QRectF;
class QtSvgPixmapCachePrivate;
class QDESIGNER_WIDGET_EXPORT QtSvgPixmapCache : public QObject
{
Q_OBJECT
public:
QtSvgPixmapCache(QObject* parent = NULL);
#endif // QT_SVG_PIXMAP_CACHE
To copy to clipboard, switch view to plain text mode
qtSvgPixmapCache.cpp
/*
....
....
...*/
/*
....
....
...*/
To copy to clipboard, switch view to plain text mode
Bookmarks