मेरे कस्टम प्लगइन अच्छा काम करता है काम निम्नलिखित कोड का उपयोग कर होगा अपनी परियोजना में पथ शामिल जाँच करनी चाहिए। इस उदाहरण में, नामस्थान न केवल प्लगइन में उपयोग किया जाता है बल्कि उस वर्ग में भी है जो प्लगइन को विरासत में लेता है। प्लगइन के लिए
हैडर --- यह है कि प्लगइन
हमेशा की तरह वर्ग को लागू करने के लिए
namespace plugin {
class MyCustomPlugin: public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
MyCustomPlugin(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 initialized;
};
}
cpp फ़ाइल QDesigner में इस्तेमाल किया जा सकता है, लेकिन निम्न विधियों में ले लेना चाहिए नामस्थान का खाता:
QString MyCustomPlugin::domXml() const
{
return "<widget class=\"plugin::MyCustomClass\" name=\"mycustomclass\">\n"
...
}
QString MyCustomPlugin::name() const
{
return "plugin::MyCustomClass";
}
QWidget *MyCustomPlugin::createWidget(QWidget *parent)
{
return new plugin::MyCustomClass(parent);
}
Q_EXPORT_PLUGIN2(mycustomplugin, plugin::MyCustomPlugin)
MyCustomClass
namespace plugin {
class QDESIGNER_WIDGET_EXPORT MyCustomClass: public MyCustomPlugin
{
Q_OBJECT
public:
MyCustomClass(QWidget * parent = 0) {}
};
}
क्यूटी का कौन सा संस्करण आप उपयोग कर रहे हैं? मुझे लगता है कि मैंने जो किया है वह करने से मुझे पुराने संस्करण का उपयोग करना चाहिए। –
अभी, क्यूटी 4.6 और क्यूटी निर्माता 2.0, लेकिन मुझे याद है कि यह पुराने संस्करणों के साथ भी काम कर रहा है। – andref
यह मेरे लिए 4.7.1 में काम किया। धन्यवाद। – cweston