Hi All
i have made a plugin for designer and it is showing in designer and i can use it only problem is that none of the propertys typical for QListwidget is visible in designer even though i did let my class subclass QListwidget. It is only the baseclass QWidget propertys that is accesible which means that i cant access a lot of the propertys that is present in QListWidget.
Now! is this not possible to achive? it seems to me it must be possible since they can make QT3plugins visible and usable in designer with all the propertys visible.
I will post my code now and see if someone can tell me if it is possible and if maybe i have done something wrong. now the only thing i have donee is to add a variable of the type QDate to the QListView but this was only so that i could figure out how the plugin was made. I am going to add more functions if i get it to show up as an extended QListWidget in Designer
dateViewList.h defining the class dateViewList and letting it subclass QListWidget
#ifndef DATEVIEWLIST_H
#define DATEVIEWLIST_H
#include <QListView>
#include <QDate>
#include <QObject>
#include <QWidget>
#include <QtDesigner/QDesignerExportWidget>
#include <QListWidget>
#include <QObject>
class QDESIGNER_WIDGET_EXPORT dateViewList
: private QListWidget {
Q_OBJECT
public :
public:
void setDate
(QDate otherDate
);
private:
};
#endif
#ifndef DATEVIEWLIST_H
#define DATEVIEWLIST_H
#include <QListView>
#include <QDate>
#include <QObject>
#include <QWidget>
#include <QtDesigner/QDesignerExportWidget>
#include <QListWidget>
#include <QObject>
class QDESIGNER_WIDGET_EXPORT dateViewList : private QListWidget {
Q_OBJECT
public :
dateViewList(QWidget *parent );
public:
void setDate(QDate otherDate);
private:
QDate displayDate;
};
#endif
To copy to clipboard, switch view to plain text mode
Implementing Class dateListView.cpp
#include "dateViewList.h"
#include <QDate>
#include <qdatetime.h>
#include <qwidget.h>
#include<QtGui>
dateViewList
:: dateViewList(QWidget *parent
){
}
void dateViewList
:: setDate(QDate otherDate
){
this->displayDate = otherDate;
}
#include "dateViewList.h"
#include <QDate>
#include <qdatetime.h>
#include <qwidget.h>
#include<QtGui>
dateViewList:: dateViewList(QWidget *parent ){
}
void dateViewList :: setDate(QDate otherDate){
this->displayDate = otherDate;
}
To copy to clipboard, switch view to plain text mode
Defining customwidgetplugin.h
#ifndef CUSTOMWIDGETPLUGIN_H
#define CUSTOMWIDGETPLUGIN_H
#include <QDesignerCustomWidgetInterface>
#include <QtPlugin>
#include <QListWidget>
{
Q_OBJECT
public: extendedListWidgetPlugin
(QWidget *parent
= 0);
bool isContainer() const;
bool isInitialized() const;
private:
bool initialized;
};
#endif
#ifndef CUSTOMWIDGETPLUGIN_H
#define CUSTOMWIDGETPLUGIN_H
#include <QDesignerCustomWidgetInterface>
#include <QtPlugin>
#include <QListWidget>
class extendedListWidgetPlugin : public QObject , public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
public: extendedListWidgetPlugin(QWidget *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;
QListWidget *createWidget(QWidget *parent);
void initialize(QDesignerFormEditorInterface *core);
private:
bool initialized;
};
#endif
To copy to clipboard, switch view to plain text mode
implementing customwidgetplugin.cpp
#include "dateViewList.h"
#include <string>
#include <qstring.h>
#include <qobject.h>
#include <qwidget.h>
#include "customwidgetplugin.h"
#include <QtPlugin>
#include <qstringlist.h>
#include <QListWidget>
extendedListWidgetPlugin
:: extendedListWidgetPlugin(QWidget *parent
){
initialized = false;
}
{
if (initialized)
return;
initialized = true;
}
{
return new dateViewList(parent);
}
bool extendedListWidgetPlugin :: isInitialized() const
{
return initialized;
}
QString extendedListWidgetPlugin
::name() const {
return "bikeDateList";
}
QString extendedListWidgetPlugin
::group() const {
return "Display Widgets [PLUGINS]";
}
QIcon extendedListWidgetPlugin
:: icon() const {
return QIcon("./hart.jpg");
}
QString extendedListWidgetPlugin
:: toolTip() const {
return "DateViewList";
}
QString extendedListWidgetPlugin
:: whatsThis() const {
return "Special widget for making Calender";
}
bool extendedListWidgetPlugin::isContainer() const
{
return true;
}
QString extendedListWidgetPlugin
:: domXml() const {
return "<widget class=\"dateViewList\" name=\"bikeDateList\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>100</width>\n"
" <height>100</height>\n"
" </rect>\n"
" </property>\n"
" <property name=\"toolTip\" >\n"
" <string>date Holder</string>\n"
" </property>\n"
" <property name=\"whatsThis\" >\n"
" <string>dateViewList holds property of the date "
"and functions to manipulate the list</string>\n"
" </property>\n"
"</widget>\n";
}
QString extendedListWidgetPlugin
::includeFile() const {
return "dateViewList.h";
}
Q_EXPORT_PLUGIN2(customwidgetplugin , extendedListWidgetPlugin)
#include "dateViewList.h"
#include <string>
#include <qstring.h>
#include <qobject.h>
#include <qwidget.h>
#include "customwidgetplugin.h"
#include <QtPlugin>
#include <qstringlist.h>
#include <QListWidget>
extendedListWidgetPlugin :: extendedListWidgetPlugin(QWidget *parent){
initialized = false;
}
void extendedListWidgetPlugin :: initialize(QDesignerFormEditorInterface * /* core */)
{
if (initialized)
return;
initialized = true;
}
QListWidget *extendedListWidgetPlugin :: createWidget(QWidget *parent)
{
return new dateViewList(parent);
}
bool extendedListWidgetPlugin :: isInitialized() const
{
return initialized;
}
QString extendedListWidgetPlugin::name() const
{
return "bikeDateList";
}
QString extendedListWidgetPlugin::group() const
{
return "Display Widgets [PLUGINS]";
}
QIcon extendedListWidgetPlugin :: icon() const
{
return QIcon("./hart.jpg");
}
QString extendedListWidgetPlugin :: toolTip() const
{
return "DateViewList";
}
QString extendedListWidgetPlugin :: whatsThis() const
{
return "Special widget for making Calender";
}
bool extendedListWidgetPlugin::isContainer() const
{
return true;
}
QString extendedListWidgetPlugin :: domXml() const
{
return "<widget class=\"dateViewList\" name=\"bikeDateList\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>100</width>\n"
" <height>100</height>\n"
" </rect>\n"
" </property>\n"
" <property name=\"toolTip\" >\n"
" <string>date Holder</string>\n"
" </property>\n"
" <property name=\"whatsThis\" >\n"
" <string>dateViewList holds property of the date "
"and functions to manipulate the list</string>\n"
" </property>\n"
"</widget>\n";
}
QString extendedListWidgetPlugin ::includeFile() const
{
return "dateViewList.h";
}
Q_EXPORT_PLUGIN2(customwidgetplugin , extendedListWidgetPlugin)
To copy to clipboard, switch view to plain text mode
I understand i may not be able to set the extra attributes and variables i add to my class in designer but all the standard things like frame and stuff that is present in a ordinary QListWidget should at least be accessible in my plugin.
Anyone familliar with plugins?
ALL thoughts are Welcome exept for ppl loking for telemarket agencies!!
Cheers
Bookmarks