[Solved] GUI plugin problems
-
Hi,
I am trying to develop a plugin system for the OpenRcon Project (http://openrcon.org/). We need to be able to create a dynamic plugin that has a ui in it. I have been following the echo plugin example http://doc.trolltech.com/4.3/tools-echoplugin.html but when i compile it i get this message "expected constructor, destructor or type convention before '(' token ". The code it is referring to is the .CPP file of the plugin where i have the Q_EXPORT_PLUGIN2(orplugin, ORPLUGIN_LIBRARY) macro.Can anyway explain why this is happening? Or how do i fix it?
-
I think it's something inside your code. But as my mystic orb is not here at the moment, it could help if you show your code. Perhaps then we cann see something...
-
Interface:
@/*
Copyright (C) 2010 The OpenRcon Project.This file is part of OpenRcon.
OpenRcon is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.OpenRcon is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with OpenRcon. If not, see http://www.gnu.org/licenses/.
/
#ifndef ORPLUGININTERFACE_H
#define ORPLUGININTERFACE_H
//
#include <QString>
#include <QIcon>
#include <QtGlobal>
/- Interface defined for the plugin system of openrcon.
/
class orPluginInterface
{
public:
/- Plugin Manager checks this first to make sure that the plugin is designed for openrcon.
- IF plugin returns false OR doesn't exist THEN the plugin is unloaded
/
virtual bool isPluginOR();
/ - The openrcon toolbar widgets are enabled/disabled based the return value of the following.
- This allows the developer to specifiy the fields that the plugin uses.
*/
virtual bool isUserAllowedToSetPortNumber();
virtual bool isUserAllowedToSetUsername();
virtual bool isUserAllowedToSetPassword();
// Allows Plugin Manager to check if plugin is enabled.
virtual bool isEnabled();
// Allows Plugin Manager to check if plugin has been (officially) signed by the openrcon.
virtual bool isSigned();
// Controls the connection and Enables/Disables the plugin.
virtual qint32 openConnection(QString hostURI, quint32 portNumber, QString username, QString password);
virtual qint32 closeConnection();
virtual qint32 enable();
virtual qint32 disable();
// Plugin details:
virtual QString getName();
virtual QString getVersion();
virtual QString getDescription();
virtual QString getDeveloper();
virtual QString getDeveloperWebsite();
virtual QString getDeveloperSupportLink();
virtual QString getPluginSystemVersion();
virtual QString getPluginSystemType(); // Defines the type of functionality the plugin extends
virtual QString getSignature();
virtual QString getPluginDefaultPortNumber();
virtual QString getConnectionStatus();
virtual QIcon getIcon();
};
Q_DECLARE_INTERFACE(orPluginInterface, "com.trolltech.Plugin.orPluginInterface/1.0");
#endif // ORPLUGININTERFACE_H
@
orPlugin.h:
@/*
Copyright (C) 2010 The OpenRcon Project.This file is part of OpenRcon.
OpenRcon is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.OpenRcon is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with OpenRcon. If not, see http://www.gnu.org/licenses/.
*/
#ifndef ORPLUGIN_H
#define ORPLUGIN_H#include "orPlugin_global.h"
#include "orplugininterface.h"class ORPLUGINSHARED_EXPORT orPlugin : public QObject, orPluginInterface {
Q_OBJECT
Q_INTERFACES(orPluginInterface)
public:
bool isPluginOR();private:
};
#endif // ORPLUGIN_H
@orPlugin.cpp:
@/*
Copyright (C) 2010 The OpenRcon Project.This file is part of OpenRcon.
OpenRcon is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.OpenRcon is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with OpenRcon. If not, see http://www.gnu.org/licenses/.
*/
#include "orplugin.h"
bool orPlugin::isPluginOR()
{
return true;
}Q_EXPORT_PLUGIN2(orplugin, ORPLUGIN_LIBRARY);
@ - Interface defined for the plugin system of openrcon.
-
Why the methods in the interface aren't pure? And, you're missing a "public" before orPluginInterface in orPlugin.h.
-
I was following the echo plugin example. I have added public orPluginInterface to or plugin.h does make a difference and made the functions to pure virtual. But still they same problem. I also have a orPlugin_global.h file
@#ifndef ORPLUGIN_GLOBAL_H
#define ORPLUGIN_GLOBAL_H#include <QtCore/qglobal.h>
#if defined(ORPLUGIN_LIBRARY)
define ORPLUGINSHARED_EXPORT Q_DECL_EXPORT
#else
define ORPLUGINSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // ORPLUGIN_GLOBAL_H@
Does that matter?
-
Your bug is clear:
C++ is case sensitive:@
Q_EXPORT_PLUGIN2(orPlugin, ORPLUGIN_LIBRARY);
@orPlugin != orplugin :-)
-
I didn't notice that, But now i am getting the same problem, and now QT creator expected identifier before numeric constant.
-
If you look at teh "docs":http://doc.qt.nokia.com/4.7/qtplugin.html#Q_EXPORT_PLUGIN2 you find the second problem:
Q_EXPORT_PLUGIN2 ( PluginName, ClassName )
Where is your class ORPLUGIN_LIBRARY ?
-
Fixed it !!! thanks for your help