PDA

View Full Version : Making Application Plugin-Aware



assismvla
23rd April 2009, 01:16
Sorry for my english ...

I am trying to developer a Application Plugin-Aware
following the "C++ GUI Programming with Qt 4 - 2nd Edition" book, but i am having a lot of trouble.

- I am use the "QT Creator"
- I am in the windows
- If a understand, i have to create a .dll file that is is my plugin, and the main app will read.
- To make the plugin i choose the "C++ Library" option in the IDE

I am attach the interface and the class that implements its (the is the plugin)

Error:
expected class-name before '(' token - Iplugin.h 12
expected initializer before '*' token - Iplugin.h 18
return type `struct QStringList' is incomplete - pluginteste.cpp 5
invalid use of undefined type `struct QStringList' - pluginteste.cpp 6
forward declaration of `struct QStringList' - qstring.h 86



// Iplugin.h

#ifndef IPLUGIN_H
#define IPLUGIN_H

#include <QtPlugin>


class QStringList;

class Iplugin
{
public:
virtual ~TextArtInterface() { }
virtual QStringList effects() const = 0;

};

Q_DECLARE_INTERFACE(TextArtInterface,
"com.software-inc.TextArt.TextArtInterface/1.0")


#endif // IPLUGIN_H




//pluginteste.h

#ifndef PLUGINTESTE_H
#define PLUGINTESTE_H

#include <QObject>
#include "Iplugin.h"

class QStringList;

class Pluginteste : public QObject , public Iplugin {

Q_OBJECT
Q_INTERFACES(Iplugin)

public:
QStringList effects() const;

};

#endif // PLUGINTESTE_H





//pluginteste.cpp

#include "pluginteste.h"


QStringList Pluginteste::effects() const
{
return QStringList() << "Plain" << "Outline" << "Shadow";
}

Q_EXPORT_PLUGIN2(pluginteste, Pluginteste);





//pluginteste.pro

# -------------------------------------------------
# Project created by QtCreator 2009-04-22T20:24:13
# -------------------------------------------------
QT -= gui
TARGET = pluginteste
TEMPLATE = lib
CONFIG += plugin
SOURCES += pluginteste.cpp
HEADERS += pluginteste.h \
Iplugin.h

Lykurg
23rd April 2009, 07:04
Hi,

expected class-name before '(' token - Iplugin.h 12
expected initializer before '*' token - Iplugin.h 18

This class has no constructor! Name of class and destructor doesn't match! Use also "#include <QStringList>."



return type `struct QStringList' is incomplete - pluginteste.cpp 5
invalid use of undefined type `struct QStringList' - pluginteste.cpp 6
forward declaration of `struct QStringList' - qstring.h 86

Use "#include <QStringList>" in top of pluginteste.cpp


... class Pluginteste has also no constructor. Maybe you want first learn the basics of C++.

assismvla
23rd April 2009, 13:29
I am still recive this error menssages:

error: expected initializer before '*' token - Iplugin.h 18
error: expected initializer before '*' token - Iplugin.h 18

Here is the files ...



//Iplugin.h

#ifndef IPLUGIN_H
#define IPLUGIN_H

#include <QtPlugin>
#include <QStringList>



class Iplugin
{
public:
Iplugin();
virtual ~Iplugin();
virtual QStringList effects() const = 0;

};

Q_DECLARE_INTERFACE(TextArtInterface,
"com.software-inc.TextArt.TextArtInterface/1.0")


#endif // IPLUGIN_H






//pluginteste.h

#ifndef PLUGINTESTE_H
#define PLUGINTESTE_H

#include <QObject>
#include <QStringList>
#include "Iplugin.h"


class Pluginteste : public QObject , public Iplugin {

Q_OBJECT
Q_INTERFACES(Iplugin)

public:
Pluginteste();
~Pluginteste();
QStringList effects() const;

};

#endif // PLUGINTESTE_H







//pluginteste.cpp

#include "pluginteste.h"
#include <QStringList>



Pluginteste::Pluginteste()
{
}

Pluginteste::~Pluginteste()
{
}

QStringList Pluginteste::effects() const
{
return QStringList() << "Plain" << "Outline" << "Shadow";
}

Q_EXPORT_PLUGIN2(pluginteste, Pluginteste);

Lykurg
23rd April 2009, 13:35
As your whole offered code doesn't contain a *, I suggest to clear all previously build things and compile new (rebuild).