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
Qt Code:
  1. CONFIG += designer \
  2. plugin \
  3. debug_and_release
  4. TARGET = $$qtLibraryTarget(speeddialplugin)
  5. TEMPLATE = lib
  6. HEADERS = speeddialplugin.h \
  7. qtsvgdialgauge.h \
  8. qtsvgpixmapcache.h
  9. SOURCES = speeddialplugin.cpp \
  10. qtsvgdialgauge.cpp \
  11. qtsvgpixmapcache.cpp
  12. RESOURCES = icons.qrc \
  13. skins.qrc
  14. LIBS += -L.
  15. target.path = $$[QT_INSTALL_PLUGINS]/designer
  16. INSTALLS += target
  17. INCLUDEPATH += $$PWD
  18. DEPENDPATH += $$PWD
  19.  
  20. # include(speeddial.pri)
  21. QT += svg
To copy to clipboard, switch view to plain text mode 


speedDialPlugin.h
Qt Code:
  1. #ifndef SPEEDDIALPLUGIN_H
  2. #define SPEEDDIALPLUGIN_H
  3.  
  4. #include <QtDesigner/QDesignerCustomWidgetInterface>
  5. #include <QObject>
  6. #include <Qt>
  7.  
  8. class speedDialPlugin : public QObject, public QDesignerCustomWidgetInterface
  9. {
  10. Q_OBJECT
  11.  
  12. public:
  13. speedDialPlugin(QObject *parent = 0);
  14.  
  15. bool isContainer() const;
  16. bool isInitialized() const;
  17. QIcon icon() const;
  18. QString domXml() const;
  19. QString group() const;
  20. QString includeFile() const;
  21. QString name() const;
  22. QString toolTip() const;
  23. QString whatsThis() const;
  24. QWidget *createWidget(QWidget *parent);
  25. void initialize(QDesignerFormEditorInterface *core);
  26.  
  27. private:
  28. bool m_initialized;
  29. };
  30.  
  31. #endif
To copy to clipboard, switch view to plain text mode 

speedDialPlugin.cpp

Qt Code:
  1. #include "qtsvgdialgauge.h"
  2. #include "speeddialplugin.h"
  3.  
  4. #include <QtCore/QtPlugin>
  5.  
  6. speedDialPlugin::speedDialPlugin(QObject *parent)
  7. : QObject(parent)
  8. {
  9. m_initialized = false;
  10. }
  11.  
  12. void speedDialPlugin::initialize(QDesignerFormEditorInterface * /* core */)
  13. {
  14. if (m_initialized)
  15. return;
  16.  
  17. // Add extension registrations, etc. here
  18.  
  19. m_initialized = true;
  20. }
  21.  
  22. bool speedDialPlugin::isInitialized() const
  23. {
  24. return m_initialized;
  25. }
  26.  
  27. QWidget *speedDialPlugin::createWidget(QWidget *parent)
  28. {
  29. //return new speedDial(parent);
  30.  
  31. QtSvgDialGauge * gauge = new QtSvgDialGauge(parent);
  32. gauge->setSkin("Tachometer");
  33. gauge->setMinimum(0);
  34. gauge->setMaximum(120);
  35. gauge->setValue(0);
  36. return gauge;
  37. }
  38.  
  39. QString speedDialPlugin::name() const
  40. {
  41. return QLatin1String("speedDial");
  42. }
  43.  
  44. QString speedDialPlugin::group() const
  45. {
  46. return QLatin1String("");
  47. }
  48.  
  49. QIcon speedDialPlugin::icon() const
  50. {
  51. return QIcon();
  52. }
  53.  
  54. QString speedDialPlugin::toolTip() const
  55. {
  56. return QLatin1String("");
  57. }
  58.  
  59. QString speedDialPlugin::whatsThis() const
  60. {
  61. return QLatin1String("");
  62. }
  63.  
  64. bool speedDialPlugin::isContainer() const
  65. {
  66. return false;
  67. }
  68.  
  69. QString speedDialPlugin::domXml() const
  70. {
  71. return QLatin1String("<widget class=\"speedDial\" name=\"speedDial\">\n</widget>\n");
  72.  
  73. }
  74.  
  75. QString speedDialPlugin::includeFile() const
  76. {
  77. return QLatin1String("hh.h");
  78. }
  79.  
  80. Q_EXPORT_PLUGIN2(speeddialplugin, speedDialPlugin)
To copy to clipboard, switch view to plain text mode 

qtSvgDialGauge.h
Qt Code:
  1. /*
  2.  
  3. */
  4.  
  5. #ifndef QT_SVG_DIAL_GAUGE
  6. #define QT_SVG_DIAL_GAUGE
  7. #include <QtGui/QWidget>
  8. #include <Qt>
  9. #include <QtCore/QPair>
  10. #include <QtDesigner/QDesignerExportWidget>
  11.  
  12. class QtSvgPixmapCache;
  13.  
  14. class QDESIGNER_WIDGET_EXPORT QtSvgDialGauge : public QWidget
  15. {
  16. Q_OBJECT
  17. Q_PROPERTY(QString skin READ skin WRITE setSkin)
  18. Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
  19. Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
  20. Q_PROPERTY(qreal startAngle READ startAngle WRITE setStartAngle)
  21. Q_PROPERTY(qreal endAngle READ endAngle WRITE setEndAngle)
  22. public:
  23. explicit QtSvgDialGauge(QWidget * parent = 0);
  24. ~QtSvgDialGauge();
  25.  
  26. void setSkin(const QString& skin);
  27. QString skin() const;
  28.  
  29.  
  30. void setMinimum(int minimum);
  31. void setMaximum(int maximum);
  32. void setNeedleOrigin(qreal x, qreal y);
  33. void setStartAngle(qreal angle);
  34. void setEndAngle(qreal angle);
  35.  
  36. int value() const;
  37. int minimum() const;
  38. int maximum() const;
  39. qreal needleOriginX() const;
  40. qreal needleOriginY() const;
  41. qreal startAngle() const;
  42. qreal endAngle() const;
  43.  
  44. virtual QSize minimumSizeHint() const;
  45. virtual QSize sizeHint() const;
  46. void setShowOverlay(bool);
  47.  
  48. public slots:
  49. void setValue(int value);
  50.  
  51. private:
  52. void init();
  53. QRectF availableRect(QtSvgPixmapCache * renderObject) const;
  54.  
  55. QtSvgPixmapCache* m_backgroundRenderer;
  56. QtSvgPixmapCache* m_needleShadowRenderer;
  57. QSvgRenderer* m_needleRenderer;
  58. QRectF availableRect(QSvgRenderer * renderObject) const;
  59. QtSvgPixmapCache* m_overlayRenderer;
  60. /** minimum possible value **/
  61. int m_minimum;
  62. /** maximum possible value **/
  63. int m_maximum;
  64. /** actual value **/
  65. int m_value;
  66. /** smallest start angle **/
  67. qreal m_startAngle;
  68. /** highest end angle **/
  69. qreal m_endAngle;
  70. /** position x of needle **/
  71. qreal m_originX;
  72. /** position y of needle **/
  73. qreal m_originY;
  74. bool m_showOverlay;
  75.  
  76. /** name of actual skin **/
  77. QString m_skin;
  78. protected:
  79. void paintEvent(QPaintEvent * event);
  80. };
  81.  
  82. #endif // QT_SVG_DIAL_GAUGE
To copy to clipboard, switch view to plain text mode 

qtSvgDialGauge.cpp
Qt Code:
  1. /*
  2.  
  3. */
  4. #include <QtGui/QPainter>
  5. #include <QtSvg/QSvgRenderer>
  6.  
  7. #include "qtsvgdialgauge.h"
  8.  
  9. #include "qtsvgpixmapcache.h"
  10.  
  11. /*!
  12.  
  13.   \class QtSvgDialGauge qtsvgdialgauge.h
  14.  
  15.  
  16.   \code
  17.  
  18.   // Create a QtSvgDialGauge
  19.   QWidget * widget = new QWidget(this)
  20.   QtSvgDialGauge * gauge = new QtSvgDialGauge(widget);
  21.   gauge->setSkin("Beryl");
  22.   widget->addWidget(gauge);
  23.   widget->show();
  24.   \endcode
  25.  
  26. /*!
  27.   Constructor of the widget with \p parent as
  28.   Parent.
  29. */
  30. QtSvgDialGauge::QtSvgDialGauge(QWidget * parent)
  31. : QWidget(parent),
  32. m_minimum(0),
  33. m_maximum(100),
  34. m_value(0),
  35. m_startAngle(0),
  36. m_endAngle(100),
  37. m_originX(0.5),
  38. m_originY(0.5),
  39. m_showOverlay(true)
  40. {
  41. init();
  42. setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
  43. }
  44.  
  45. /*!
  46.   Destructor
  47. */
  48. QtSvgDialGauge::~QtSvgDialGauge()
  49. {
  50. }
  51.  
  52.  
  53.  
  54. /*.....
  55. ......
  56. .....
  57. .....
  58. .....
  59. .....*/
  60. }
To copy to clipboard, switch view to plain text mode 

qtSvgPixmapCache.h
Qt Code:
  1. /*
  2.  
  3. */
  4.  
  5.  
  6. #ifndef QT_SVG_PIXMAP_CACHE
  7. #define QT_SVG_PIXMAP_CACHE
  8.  
  9. #include <QtCore/QSizeF>
  10. #include <Qt>
  11. #include <QObject>
  12. #include <QtDesigner/QDesignerExportWidget>
  13.  
  14.  
  15. class QPainter;
  16. class QString;
  17. class QRectF;
  18.  
  19. class QtSvgPixmapCachePrivate;
  20.  
  21. class QDESIGNER_WIDGET_EXPORT QtSvgPixmapCache : public QObject
  22. {
  23. Q_OBJECT
  24.  
  25. public:
  26. QtSvgPixmapCache(QObject* parent = NULL);
  27.  
  28. #endif // QT_SVG_PIXMAP_CACHE
To copy to clipboard, switch view to plain text mode 

qtSvgPixmapCache.cpp
Qt Code:
  1. /*
  2. ....
  3. ....
  4. ...*/
To copy to clipboard, switch view to plain text mode