PDA

View Full Version : Managing widget plugin in Qt Designer



yellowmat
30th January 2006, 09:02
Hi there,

It's me again.

So , now that My first widget plugin source code compile, I see something strange. My plugin does not appear in the "Custom Widgets" category, instead a new category also called "Custom Widgets" has been created but does not contain any plugin. If a choose a different category such as "Input", my widget is added into that category.

So what's wrong with this ? What should I do to add my plugin in the "Custom Widgets" category ?

Thanks in advance

high_flyer
30th January 2006, 10:45
can you post your QWidgetPlugin subclass implementation?

yellowmat
30th January 2006, 11:06
Here it is :

#include "ColorChooserPlugin.h"
#include ".\\..\\WidgetSource\\ColorChooser.h"

CColorChooserPlugin::CColorChooserPlugin()
:QWidgetPlugin()
{

}

QStringList CColorChooserPlugin::keys() const
{
QStringList list;
list << "CColorChooserPlugin";
return list;
}

QWidget* CColorChooserPlugin::create(const QString& key, QWidget* parent, const char* name)
{
if( key == "CColorChooserPlugin" )
return new CColorChooser(parent, name);
return 0;
}

QString CColorChooserPlugin::includeFile(const QString& feature) const
{
if( feature == "CColorChooserPlugin" )
return "ColorChooser.h";
return QString::null;
}

QString CColorChooserPlugin::group(const QString& feature) const
{
if( feature == "CColorChooserPlugin" )
return "Custom Widgets";
return QString::null;
}

QIconSet CColorChooserPlugin::iconSet(const QString& feature) const
{
return QIconSet( QPixmap("colorchooser_pixmap.png"));
}

QString CColorChooserPlugin::toolTip(const QString& feature) const
{
if( feature == "CColorChooserPlugin" )
return "Color Chooser Widget";
return QString::null;
}

QString CColorChooserPlugin::whatsThis(const QString& feature) const
{
if( feature == "CColorChooserPlugin" )
return "A widget to choose a color";
return QString::null;
}

bool CColorChooserPlugin::isContainer(const QString& feature) const
{
return FALSE;
}

Q_EXPORT_PLUGIN( CColorChooserPlugin );

yellowmat
30th January 2006, 11:17
Another question is how to integrate and use a plugin into an application.

Should I include any headers or anything else ?

high_flyer
30th January 2006, 13:09
My plugin does not appear in the "Custom Widgets" category, instead a new category also called "Custom Widgets" has been created but does not contain any plugin. If a choose a different category such as "Input", my widget is added into that category.
I don't see any thing wrong with your code, that could explain that behaviour.


Should I include any headers or anything else ?
Yes, include the headers of your plugin, and link to the *.so/*.dll like a normal library.

yellowmat
30th January 2006, 15:57
Ok, it works

high_flyer
30th January 2006, 16:36
Would you mind sharing what was the problem and the solution?:)

yellowmat
30th January 2006, 16:52
Yes,

So I still don't know why the plugin never appears in the category "Custom Widget" when I specify it, and I don't know yet why it appears in the 'Input" category when I specify it. For the moment I add it to "Input" ... I know it is not a clean solution but I don't have time to find out why for the moment.

About the usage of a plugin, I add it in my dialog with Qt Designer, then I add the header file in the implementation still with Qt Designer. Then with Visual C++ 6.0, I add the .cpp, the .h and the moc file of my widget.

sunil.thaha
31st January 2006, 10:58
Yes,

About the usage of a plugin, I add it in my dialog with Qt Designer, then I add the header file in the implementation still with Qt Designer. Then with Visual C++ 6.0, I add the .cpp, the .h and the moc file of my widget.


You need not include the .moc, .cpp
The whole idea of creating a .so/.dll is that you need not include it in the project. Instead use the.
LIBS += -lfilechooser in your .pro

the Application will be linked to that