Showing posts with label custom widget. Show all posts
Showing posts with label custom widget. Show all posts

Tuesday, September 29, 2009

How to create custom widgets

First, create your custom widget use Qt creator. To wrap up, do the following:

In Interface.h file:

#include QtDesigner
#include "PushButtonPlugin.h"
#include "AnimatedLabelPlugin.h"
#include "LabelPlugin.h"
#include "TextEntryPlugin.h"

//Interface for all Widgets
class MyCustomWidgets: public QObject, public QDesignerCustomWidgetCollectionInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)

public:
MyCustomWidgets(QObject *parent = 0) : QObject(parent)
{
widgets.append(new PushButtonPlugin(this));
widgets.append(new AnimatedLabelPlugin(this));
widgets.append(new LabelPlugin(this));
widgets.append(new TextEntryPlugin(this));
}

virtual QList customWidgets() const
{
return widgets;
}

private:
QList widgets;
};

In Interface.cpp file:
#include "Interface.h"

Q_EXPORT_PLUGIN2(customwidgetsplugin,MyCustomWidgets);