bin grade dabei mir ein eigenes Widget für den Designer zu schreiben.
Ich halte mich dabei an das Custom Widget Plugin Example(aus den Examples).
Allerdings knallt es bei mir noch ...
navigationdesignerplugin.cpp:83: error: expected constructor, destructor, or type conversion at end of input
make: *** [navigationdesignerplugin.o] Error 1
class NavigationDesignerPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
NavigationDesignerPlugin(QObject *parent = 0);
/*
Since we (need to) implement QDesignerCustomWidgetInterface we need to fill this with some code
so the QtDesigner can load the plugin.
*/
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;
};
Jemand von euch eine Idee????
#include "navigationdesignerplugin.h"
#include "navigationwidget.h"
NavigationDesignerPlugin::NavigationDesignerPlugin(QObject *parent /*== NULL BY DEFAULT*/ )
{
Q_UNUSED(parent) // right now we do not need this
this->initialized = false; // we're not initialized here!!!
}
void NavigationDesignerPlugin::initialize(QDesignerFormEditorInterface *core)
{
Q_UNUSED(core) // we don't need this
if (initialized)
return;
this->initialized = true;
}
bool NavigationDesignerPlugin::isInitialized() const
{
return this->initialized;
}
QWidget *NavigationDesignerPlugin::createWidget(QWidget *parent)
{
return new NavigationWidget(parent); // right here we create an instance of the visible stuff and return the ptr to the new widget!
}
QString NavigationDesignerPlugin::name() const
{
return "Navigation Widget";
}
QString NavigationDesignerPlugin::group() const
{
return "Custom Controls";
}
QIcon NavigationDesignerPlugin::icon() const
{
return QIcon(":/images/systray_active.ico");
}
QString NavigationDesignerPlugin::toolTip() const
{
return "main navigation Widget";
}
QString NavigationDesignerPlugin::whatsThis() const
{
return "";
}
bool NavigationDesignerPlugin::isContainer() const
{
// The isContainer() function tells Qt Designer whether the widget is supposed to be used as a container for other widgets.
//If not, Qt Designer will not allow the user to place widgets inside it.
return true;
}
QString NavigationDesignerPlugin::domXml() const
{
return "<ui language=\"c++\">\n"
" <widget class=\"NavigationWidget\" name=\"navigationwidget\">\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"
" </widget>\n"
"</ui>\n";
}
QString NavigationDesignerPlugin::includeFile() const
{
return "navigationwidget.h";
}
Q_EXPORT_PLUGIN2(navigationdesignerplugin, NavigationDesignerPlugin)
Das kann sein.. ich nimm bei diesem Fehler immer QtGui (weil ich in den Plugins häufig viele andere Qt-Gui-Klassen benötige), aber vermutlich reicht auch eine kleinere Header.
AuE hat geschrieben:Im "Designer" sieht es so aus wie es aussehen soll, im Designer vom Creator sehe ich nix.
Hihi
Das ist natürlich doof...
Creator neustarten? Ansonsten schaut das nach nem Bug aus. Denn der in den Creator eingebettete Designer sollte eigentlich genau das selbe machen können wie die Standalone-app.
Oder kann es sein, dass du verschiedene Qt-Installationen bzw. dein Plugin mehrfach unter verschiedenen Namen installiert hast?
Ich denke mal das Problem ist das der Designer woanders liegt als der Creator!
Die Pfade sind auch unterschiedlich => Wenn ich den Designer starte dann hat dieser eine ganze Menge an Plugins drin (alles was unter QTDIR/qt/plugins/designer liegt. Der Creator hingegen hat nur die Sachen die unter QTDIR/bin/designer liegen