Results 1 to 7 of 7

Thread: interface on plugin

  1. #1
    Join Date
    Aug 2006
    Location
    Some where in Argentina
    Posts
    23
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Unhappy interface on plugin

    when I try to compile my plugin, I get this error:

    compilando presupuesto.cpp (g++)
    presupuesto.h:45: error: ISO C++ forbids declaration of 'EPresupuesto' with no type
    presupuesto.h:45: error: expected ';' before '*' token
    presupuesto.cpp: In constructor 'Presupuesto::Presupuesto(QObject*)':
    presupuesto.cpp:65: error: '_plugin' was not declared in this scope
    presupuesto.cpp:65: error: 'EPresupuesto' was not declared in this scope
    presupuesto.cpp:65: error: parse error in template argument list
    presupuesto.cpp:65: error: no matching function for call to 'qobject_cast(QObject*)'

    but the code is the next:

    Qt Code:
    1. if( loader->load() )
    2. {
    3. _plugin = qobject_cast<EPresupuesto *>(loader->instance());
    To copy to clipboard, switch view to plain text mode 
    and in the class is declared as follows:
    Qt Code:
    1. private:
    2. EPresupuesto *_plugin;
    To copy to clipboard, switch view to plain text mode 
    the include is present and the interface is
    Qt Code:
    1. #include <QtPlugin>
    2. class QString;
    3. class QSqlRecord;
    4. /**
    5.  * \brief Interfaz de presupuesto
    6.  *
    7.  * Interfaz para especificaciones del plugin presupuesto
    8.  *
    9.  * @author Esteban Zeller <juiraze@yahoo.com.ar>
    10. */
    11. class EPresupuesto
    12. {
    13. public:
    14. virtual ~EPresupuesto() {}
    15. virtual QString nombre() const = 0;
    16. virtual double version() const = 0;
    17. virtual void setRegistro( QSqlRecord *rec ) = 0;
    18. virtual QString obtenerHtml() = 0;
    19. virtual QString obtenerContenido() = 0;
    20. };
    21.  
    22. Q_DECLARE_INTERFACE(EPresupuesto,
    23. "tranfuga.EPresupuesto/1.0" )
    To copy to clipboard, switch view to plain text mode 
    Where is the problem???
    thanks in advance

  2. #2
    Join Date
    Jan 2008
    Location
    Brasil
    Posts
    131
    Thanks
    18
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: interface on plugin

    You included the head of the class?

  3. #3
    Join Date
    Aug 2006
    Location
    Some where in Argentina
    Posts
    23
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: interface on plugin

    Quote Originally Posted by estanisgeyer View Post
    You included the head of the class?
    Yes. the epresupuesto.h file...

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: interface on plugin

    Could you clarify where the interface is declared and which file includes and what?
    J-P Nurmi

  5. #5
    Join Date
    Aug 2006
    Location
    Some where in Argentina
    Posts
    23
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: interface on plugin

    the file presupuesto.cpp:
    Qt Code:
    1. #ifndef EPRESUPUESTO_H
    2. #define EPRESUPUESTO_H
    3.  
    4. #include <QObject>
    5. class QSqlRecord;
    6. #include <QPluginLoader>
    7. #include <epresupuesto.h>
    8. class QPainter;
    9. /**
    10.  * \brief Clase de presupuesto
    11.  *
    12.  * Clase que sirve como contenedor de un presupuesto y puede hacer todas sus operaciones
    13.  *
    14.  * @author Esteban Zeller <juiraze@yahoo.com.ar>
    15.  */
    16. class Presupuesto : public QObject
    17. {
    18. Q_OBJECT
    19. public:
    20. Presupuesto(QObject *parent = 0);
    21. ~Presupuesto();
    22. QSqlRecord registro( int id );
    23. void imprimir( QPainter *pintador );
    24.  
    25. private:
    26. EPresupuesto *_plugin;
    27. QPluginLoader *loader;
    28. };
    29.  
    30. #endif
    To copy to clipboard, switch view to plain text mode 
    in the file presupuesto.cpp:
    Qt Code:
    1. #include "presupuesto.h"
    2.  
    3.  
    4. #include <QDir>
    5. #include <QApplication>
    6. #include <QSqlRecord>
    7. #include <QPainter>
    8. #include "eplugin.h"
    9.  
    10. #include "prespuesto.h"
    11. #include <QMessageBox>
    12.  
    13. Presupuesto::Presupuesto(QObject *parent)
    14. : QObject(parent)
    15. {
    16. loader = new QPluginLoader( this );
    17. // Busco los plugins de presupuestos
    18. QDir pluginsDir = QDir(qApp->applicationDirPath());
    19.  
    20. #if defined(Q_OS_WIN)
    21. if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
    22. pluginsDir.cdUp();
    23. #elif defined(Q_OS_MAC)
    24. if (pluginsDir.dirName() == "MacOS") {
    25. pluginsDir.cdUp();
    26. pluginsDir.cdUp();
    27. pluginsDir.cdUp();
    28. }
    29. #endif
    30. pluginsDir.cd("plugins");
    31. pluginsDir.cd("presupuesto");
    32. #ifdef Q_WS_WIN32
    33. QStringList filtro;
    34. filtro.append( "*.dll" );
    35. #endif
    36. // Obtengo el nombre del plugin de infoprog actual para cargar el del mismo nombre
    37. int pos = pluginsDir.entryList( QDir::Files ).indexOf( prespuesto::pref()->value( "pluginInfo", "default" ).toString() );
    38. if( pos == -1 )
    39. {
    40. QMessageBox::critical( 0, "Error", "No existe ningun plugin de presupuestos definidos! Verifique la instalación!" );
    41. return;
    42. }
    43. loader->setFileName( pluginsDir.absoluteFilePath( pluginsDir.entryList( QDir::Files ).at( pos ) ) );
    44. if( loader->load() )
    45. {
    46. _plugin = qobject_cast<EPresupuesto *>(loader->instance());
    47.  
    48. }
    49. else
    50. {
    51. qWarning( "Error al cargar el plugin" );
    52. qWarning( QString( "Error: %1" ).arg( loader->errorString() ).toLocal8Bit() );
    53. }
    54. // Fin de la carga del plugin
    55. }
    56.  
    57.  
    58. Presupuesto::~Presupuesto()
    59. {
    60. }
    To copy to clipboard, switch view to plain text mode 
    the include file that contains the interface it this:
    Qt Code:
    1. #ifndef EPRESUPUESTO_H
    2. #define EPRESUPUESTO_H
    3.  
    4. #include <QtPlugin>
    5. class QString;
    6. class QSqlRecord;
    7. /**
    8.  * \brief Interfaz de presupuesto
    9.  *
    10.  * Interfaz para especificaciones del plugin presupuesto
    11.  *
    12.  * @author Esteban Zeller <juiraze@yahoo.com.ar>
    13. */
    14. class EPresupuesto
    15. {
    16. public:
    17. virtual ~EPresupuesto() {}
    18. virtual QString nombre() const = 0;
    19. virtual double version() const = 0;
    20. virtual void setRegistro( QSqlRecord *rec ) = 0;
    21. virtual QString obtenerHtml() = 0;
    22. virtual QString obtenerContenido() = 0;
    23. };
    24.  
    25. Q_DECLARE_INTERFACE(EPresupuesto,
    26. "tranfuga.EPresupuesto/1.0" )
    27.  
    28. #endif
    To copy to clipboard, switch view to plain text mode 

    all the sintaxis and definitions are ok, but the compiler dont get the class EPresupuesto like a valid class...
    all this clasess are inside a Qt Plugin....

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: interface on plugin

    You have the same define guard EPRESUPUESTO_H in two different header files.
    J-P Nurmi

  7. The following user says thank you to jpn for this useful post:

    tranfuga25s (6th March 2008)

  8. #7
    Join Date
    Aug 2006
    Location
    Some where in Argentina
    Posts
    23
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Cool Re: interface on plugin

    Thanks! Many thanks...

Similar Threads

  1. QPluginLoader not recognizing a plugin
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 14:13
  2. plugin loading problem
    By naresh in forum Qt Programming
    Replies: 6
    Last Post: 9th June 2007, 19:05
  3. Qt4 win opensource + mysql plugin
    By vr in forum Installation and Deployment
    Replies: 3
    Last Post: 25th May 2007, 09:01
  4. Application plugin on windows
    By Eyee in forum Qt Programming
    Replies: 2
    Last Post: 22nd March 2006, 17:36
  5. Qt interface running extremely slowly...
    By jazztpt in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2006, 11:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.