qt-interest@trolltech.com
[Top] [All Lists]

[Qt4] Creating an app that suports plugin via Qt

Subject: [Qt4] Creating an app that suports plugin via Qt
From: "Thiago Santos"
Date: Mon, 27 Mar 2006 13:13:27 -0300

Hi guys, I'm having a problem to build an application that suports plugins.
Every time I try to compile the app plugin, the compilation fails!
Have a look at my plugin project:

ps.: '../../lib' exists and it contains all interfaces under the directory 'plugininterfaces'

QMake project file:
***********************************************************
ROOT = ../..

TEMP_FILES = $${ROOT}/temp/cpp_plugin
OBJS_FILES = $${ROOT}/objs/cpp_plugin

TEMPLATE = lib

CONFIG += plugin \
          warn_on

MOC_DIR                  = $$TEMP_FILES
OBJECTS_DIR              = $$OBJS_FILES
RCC_DIR                  = $$TEMP_FILES
DESTDIR                  = $${ROOT}/build/plugins

INCLUDEPATH += ../../lib $$TEMP_FILES
LIBS        += -lSphere -L$${ROOT}/build/lib

TARGET = cpp_plugin

HEADERS += cppplugin.h

SOURCES += cppplugin.cpp

***********************************************************

Header:
***********************************************************
#ifndef CPPPLUGIN_H_
#define CPPPLUGIN_H_

#include <QObject>
#include "plugininterfaces/infointerface.h"
#include "plugininterfaces/editorinterface.h"

class EditorWidget;

class CppPlugin : public QObject,
                                  public InfoInterface,
                                  public EditorInterface
{
        Q_OBJECT
        Q_INTERFACES(InfoInterface EditorInterface)
       
        public:
                CppPlugin();
                virtual ~CppPlugin() { }

                // Info
                QString name();
                int types();
               
                // Editor
                QString filter() const;
                QWidget* editor();
               
        private:
                EditorWidget* _editor;
};

#endif /*CPPPLUGIN_H_*/
***********************************************************

Source:
***********************************************************
#include "cppplugin.h"
#include "editorwidget.h"

#include <QString>
#include <QWidget>

CppPlugin::CppPlugin() : QObject(), InfoInterface(), EditorInterface() {
        _editor = new EditorWidget();
}

QString CppPlugin::name() {
        return "C/C++ Environment Plugin";
}

int CppPlugin::types() {
        return FileEditor | ProjectMenager;
}

QString CppPlugin::filter() const {
        return "C/All C++ files (*.c *.cc *.cpp *.cxx *.cxx *.h *.hh *.hxx)";
}

QWidget* CppPlugin::editor() {
        return _editor;
}

Q_EXPORT_PLUGIN2(cpp_plugin, CppPlugin)
***********************************************************

Make process:
***********************************************************
C:\EclipseQt\Workspace\SphereIDE\plugins\cpp>qmake

C:\EclipseQt\Workspace\SphereIDE\plugins\cpp>make
make -f Makefile.Debug
make[1]: Entering directory `C:/EclipseQt/Workspace/SphereIDE/plugins/cpp'
g++ -c -g -g -Wall -frtti -fexceptions -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_PLUGIN -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"C:/Qt/snapshot/include/QtCore" -I"C:/Qt/snapshot/include/QtGui" -I"C:/Qt/snapshot/include" -I"..\..\lib" -I"..\..\temp\cpp_plugin" -I"C:/Qt/snapshot/include/ActiveQt" -I"..\..\temp\cpp_plugin" -I"." -I"C:/Qt/snapshot/mkspecs/win32-g++" -o ..\..\objs\cpp_plugin\cppplugin.o cppplugin.cpp

cppplugin.cpp:27: error: expected constructor, destructor, or type conversion before '(' token
cppplugin.cpp:27: error: expected `,' or `;' before '(' token
make[1]: *** [..\..\objs\cpp_plugin\cppplugin.o] Error 1
make[1]: Leaving directory `C:/EclipseQt/Workspace/SphereIDE/plugins/cpp'
make: *** [debug] Error 2
***********************************************************

What I'm doing wrong?
tks


--
Thiago dos Santos Alves
Computer Scientist

thiago.salves@xxxxxxxxx
-----------------------------------------------------
"A mente que se abre a uma nova idéia jamais voltará ao seu tamanho original."
- Albert Einstein
<Prev in Thread] Current Thread [Next in Thread>