Greetings,

anyone got QT4 plugins to work yet, other than the PlugAndPaint demo supplied with QT4.1.2 ?

I'm using QT 4.1.2, mingw compiler and Windows 2000.

I'm able to get the above demo to compile, but when I try to build my own simple test setup, I continually get this error :

plugin.cpp:10: error: expected constructor, destructor, or type conversion before '(' token
plugin.cpp:10: error: expected `,' or `;' before '(' token
mingw32-make[1]: *** [release\plugin.o] Error 1

For now, everything is in the same folder. I have three files :

The interface header :

Qt Code:
  1. class QString;
  2.  
  3. class PluginInterface {
  4. public:
  5. // Destructor - does nothing.
  6. virtual ~PluginInterface() {}
  7.  
  8. // Simple interface - returns some text in a QString.
  9. virtual QString GetText() const = 0;
  10. };
  11.  
  12. Q_DECLARE_INTERFACE(PluginInterface, "dunbar-it.co.uk.test.TextInterface/1.0")
To copy to clipboard, switch view to plain text mode 


The header file for my plugin :

Qt Code:
  1. #ifndef plugin_h
  2. #define plugin_h
  3.  
  4. #include <QObject>
  5. #include <QString>
  6.  
  7. #include "interfaces.h"
  8.  
  9. class TextPlugin : public QObject, public PluginInterface {
  10. Q_OBJECT
  11. Q_INTERFACES(PluginInterface)
  12.  
  13. public:
  14. // Destructor - does nothing.
  15. ~TextPlugin() {}
  16.  
  17. // Simple interface - returns some text in a QString.
  18. QString GetText();
  19. };
  20.  
  21. #endif
To copy to clipboard, switch view to plain text mode 
The plugin source file :

Qt Code:
  1. #include "plugin.h"
  2.  
  3. QString TextPlugin::GetText()
  4. {
  5. return QString("This is some text.");
  6. }
  7.  
  8. //Q_EXPORT_PLUGIN2(PlugIn_Name, Plugin_class)
  9.  
  10. Q_EXPORT_PLUGIN2(plugin, TextPlugin)
To copy to clipboard, switch view to plain text mode 
The project file is named 'plugin.pro' and contains the following :

Qt Code:
  1. TEMPLATE = lib
  2. CONFIG += plugin
  3. HEADERS = plugin.h
  4. SOURCES = plugin.cpp
  5. DESTDIR = ../plugins
  6.  
  7. contains(TEMPLATE,lib) {
  8. CONFIG(debug, debug|release) {
  9. unix:TARGET = $$member(TARGET, 0)_debug
  10. else:TARGET = $$member(TARGET, 0)d
  11. }
  12. }
To copy to clipboard, switch view to plain text mode 

The error message only appears when I have the Q_EXPORT_PLUGIN2 macro in my cpp file. The error line is indeed that line.

Any hints and tipe from those of you much better than I am at QT and C++ programming will be gratefully received. Thanks.

Cheers,
Norman.