Results 1 to 11 of 11

Thread: Custom Plugin problem to build

  1. #1
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Custom Plugin problem to build

    Hi guys!!

    I have to do some custom plugins to use with designer, but I'm having problems to build it!

    This message is shown when I try to build:

    hudson@brevleq:~/documentos/7º periodo/sistemas distribuidos/fontes/SpinViewPlugin$ make
    make -f Makefile.Release
    make[1]: Entrando no diretório `/home/hudson/documentos/7º periodo/sistemas distribuidos/fontes/SpinViewPlugin'
    g++ -c -pipe -O2 -D_REENTRANT -Wall -W -fPIC -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SCRIPT_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQDESIGNER_EXPORT_WIDGETS -DQT_SHARED -I/opt/qt4/mkspecs/linux-g++ -I. -I/opt/qt4/include/QtDesigner -I/opt/qt4/include/QtCore -I/opt/qt4/include/QtCore -I/opt/qt4/include/QtGui -I/opt/qt4/include/QtGui -I/opt/qt4/include/QtXml -I/opt/qt4/include/QtXml -I/opt/qt4/include/QtScript -I/opt/qt4/include/QtScript -I/opt/qt4/include -I. -Icontainer -Iporta -Iobserver -Iobserver/events -Icontroller -Iview -Igenerator -Irelease -I. -o release/SpinViewPlugin.o SpinViewPlugin.cpp
    SpinViewPlugin.cpp:49: error: expected constructor, destructor, or type conversion before '(' token
    make[1]: ** [release/SpinViewPlugin.o] Erro 1
    make[1]: Saindo do diretório `/home/hudson/documentos/7º periodo/sistemas distribuidos/fontes/SpinViewPlugin'
    make: ** [release] Erro 2
    hudson@brevleq:~/documentos/7º periodo/sistemas distribuidos/fontes/SpinViewPlugin$
    These are the source files:

    Qt Code:
    1. #ifndef SPINVIEWPLUGIN_H
    2. #define SPINVIEWPLUGIN_H
    3.  
    4. #include <QString>
    5. #include <QDesignerCustomWidgetInterface>
    6. #include "SpinView.h"
    7.  
    8. /// class SpinViewPlugin -
    9. class SpinViewPlugin : public QObject,public QDesignerCustomWidgetInterface {
    10. Q_OBJECT
    11.  
    12. public:
    13. SpinViewPlugin(QObject *parent=0);
    14.  
    15. QString name() const;
    16. QString includeFile() const;
    17. QString group() const;
    18. QIcon icon() const;
    19. QString toolTip() const;
    20. QString whatsThis() const;
    21. bool isContainer() const;
    22. QWidget *createWidget(QWidget *parent);
    23.  
    24. bool isInitialized() const;
    25. void initialize(QDesignerFormEditorInterface *core);
    26.  
    27. private:
    28. bool initialized;
    29.  
    30. };
    31.  
    32. #endif
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "SpinViewPlugin.h"
    2.  
    3. SpinViewPlugin::SpinViewPlugin(QObject *parent):QObject(parent){
    4. initialized = false;
    5. }
    6.  
    7. void SpinViewPlugin::initialize(QDesignerFormEditorInterface *){
    8. if (initialized)
    9. return;
    10. initialized = true;
    11. }
    12.  
    13. bool SpinViewPlugin::isInitialized() const{
    14. return initialized;
    15. }
    16.  
    17. QString SpinViewPlugin::name() const{
    18. return "SpinView";
    19. }
    20.  
    21. QString SpinViewPlugin::includeFile() const{
    22. return "SpinView.h";
    23. }
    24.  
    25. QString SpinViewPlugin::group() const{
    26. return tr("Brevleq's widgets");
    27. }
    28.  
    29. QIcon SpinViewPlugin::icon() const{
    30. return QIcon("/opt/qt4/doc/src/images/plastique-spinbox.png");
    31. }
    32.  
    33. QString SpinViewPlugin::toolTip() const{
    34. return tr("MVC's View");
    35. }
    36.  
    37. QString SpinViewPlugin::whatsThis() const{
    38. return tr("This widget is used like View in MVC pattern!");
    39. }
    40.  
    41. bool SpinViewPlugin::isContainer() const{
    42. return false;
    43. }
    44.  
    45. QWidget *SpinViewPlugin::createWidget(QWidget *parent){
    46. return(new SpinView(parent));
    47. }
    48.  
    49. Q_EXPORT_PLUGIN2(customwidgetplugin, SpinViewPlugin)
    To copy to clipboard, switch view to plain text mode 

    The problem is happening in the last line of cpp file!

    here is my *.pro file:

    TEMPLATE = lib
    CONFIG += designer \
    plugin \
    debug_and_release

    DEPENDPATH += . \
    container \
    controller \
    frontend \
    generator \
    observer \
    porta \
    view \
    observer/events
    INCLUDEPATH += . \
    container \
    porta \
    observer \
    observer/events \
    controller \
    view \
    generator

    # Input
    HEADERS += SpinViewPlugin.h \
    container/CLP.h \
    controller/Controller.h \
    controller/TypeWriter.h \
    controller/ValueWriter.h \
    frontend/FrontEnd.h \
    generator/BGenerator.h \
    generator/CGenerator.h \
    generator/Generator.h \
    generator/QGenerator.h \
    generator/TGenerator.h \
    observer/Observer.h \
    observer/Subject.h \
    porta/Porta.h \
    porta/PortaEntrada.h \
    porta/PortaSaida.h \
    view/ComboView.h \
    view/SpinView.h \
    view/View.h \
    observer/events/Event.h \
    observer/events/ValueChangedEvent.h
    FORMS += frontend/FrontEnd.ui
    SOURCES += SpinViewPlugin.cpp \
    container/CLP.cpp \
    controller/Controller.cpp \
    controller/TypeWriter.cpp \
    controller/ValueWriter.cpp \
    generator/BGenerator.cpp \
    generator/CGenerator.cpp \
    generator/QGenerator.cpp \
    generator/TGenerator.cpp \
    observer/Subject.cpp \
    porta/Porta.cpp \
    porta/PortaEntrada.cpp \
    porta/PortaSaida.cpp \
    view/ComboView.cpp \
    view/SpinView.cpp \
    view/View.cpp \
    observer/events/Event.cpp \
    observer/events/ValueChangedEvent.cpp
    DESTDIR = $(QTDIR)/plugins/designer
    What should I do to build correctly this plugin??

  2. #2
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: Custom Plugin problem to build

    Hi,

    Qt Code:
    1. Q_EXPORT_PLUGIN2 ( PluginName, ClassName )
    2. This macro exports the plugin class ClassName for the plugin specified by PluginName. The value of PluginName should correspond to the TARGET specified in the plugin's project file.
    3. There should be exactly one occurrence of this macro in the source code for a Qt plugin, and it should be used where the implementation is written rather than in a header file.
    4. Example:
    5. Q_EXPORT_PLUGIN2(pnp_extrafilters, ExtraFiltersPlugin)
    To copy to clipboard, switch view to plain text mode 

    Not sure, but it might help to rename the plugin name and to add a target to *pro with the same name.

  3. #3
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom Plugin problem to build

    The problem still happen:

    hudson@brevleq:~/documentos/7º periodo/sistemas distribuidos/fontes/SpinView_plugin$ make
    make -f Makefile.Release
    make[1]: Entrando no diretório `/home/hudson/documentos/7º periodo/sistemas distribuidos/fontes/SpinView_plugin'
    g++ -c -pipe -O2 -D_REENTRANT -Wall -W -fPIC -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SCRIPT_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQDESIGNER_EXPORT_WIDGETS -DQT_SHARED -I/opt/qt4/mkspecs/linux-g++ -I. -I/opt/qt4/include/QtDesigner -I/opt/qt4/include/QtCore -I/opt/qt4/include/QtCore -I/opt/qt4/include/QtGui -I/opt/qt4/include/QtGui -I/opt/qt4/include/QtXml -I/opt/qt4/include/QtXml -I/opt/qt4/include/QtScript -I/opt/qt4/include/QtScript -I/opt/qt4/include -I. -Iview -Iporta -Iobserver -Iobserver/events -Icontroller -Icontainer -Igenerator -Irelease -I. -o release/SpinViewPlugin.o SpinViewPlugin.cpp
    SpinViewPlugin.cpp:49: error: expected constructor, destructor, or type conversion before '(' token
    make[1]: ** [release/SpinViewPlugin.o] Erro 1
    make[1]: Saindo do diretório `/home/hudson/documentos/7º periodo/sistemas distribuidos/fontes/SpinView_plugin'
    make: ** [release] Erro 2
    hudson@brevleq:~/documentos/7º periodo/sistemas distribuidos/fontes/SpinView_plugin$
    I've put this in my SpinView_plugin.pro:

    TARGET = SpinView_plugin
    and put this in my source:

    Q_EXPORT_PLUGIN2(SpinView_plugin, SpinViewPlugin)
    I think QT isn't identifying his macro.

  4. #4
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: Custom Plugin problem to build

    Did you run qmake again and made a clean release build?

  5. #5
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: Custom Plugin problem to build

    I've did it!

    I've changed pro file again, based in QT's example:

    ################################################## ####################
    # Automatically generated by qmake (2.01a) dom dez 21 10:02:14 2008
    ################################################## ####################

    CONFIG += designer plugin debug_and_release
    TARGET = $$qtLibraryTarget($$TARGET)
    TEMPLATE = lib
    QTDIR_buildESTDIR = $$QT_BUILD_TREE/plugins/designer

    DEPENDPATH += . \
    container \
    controller \
    frontend \
    generator \
    observer \
    porta \
    view \
    observer/events
    INCLUDEPATH += . \
    container \
    porta \
    observer \
    observer/events \
    controller \
    view \
    generator

    # Input
    HEADERS += SpinViewPlugin.h \
    container/CLP.h \
    controller/Controller.h \
    controller/TypeWriter.h \
    controller/ValueWriter.h \
    frontend/FrontEnd.h \
    generator/BGenerator.h \
    generator/CGenerator.h \
    generator/Generator.h \
    generator/QGenerator.h \
    generator/TGenerator.h \
    observer/Observer.h \
    observer/Subject.h \
    porta/Porta.h \
    porta/PortaEntrada.h \
    porta/PortaSaida.h \
    view/ComboView.h \
    view/SpinView.h \
    view/View.h \
    observer/events/Event.h \
    observer/events/ValueChangedEvent.h
    FORMS += frontend/FrontEnd.ui
    SOURCES += SpinViewPlugin.cpp \
    container/CLP.cpp \
    controller/Controller.cpp \
    controller/TypeWriter.cpp \
    controller/ValueWriter.cpp \
    generator/BGenerator.cpp \
    generator/CGenerator.cpp \
    generator/QGenerator.cpp \
    generator/TGenerator.cpp \
    observer/Subject.cpp \
    porta/Porta.cpp \
    porta/PortaEntrada.cpp \
    porta/PortaSaida.cpp \
    view/ComboView.cpp \
    view/SpinView.cpp \
    view/View.cpp \
    observer/events/Event.cpp \
    observer/events/ValueChangedEvent.cpp

    # install
    target.path = $$[QT_INSTALL_PLUGINS]/designer
    sources.files = $$SOURCES $$HEADERS *.pro
    sources.path = $$[QT_INSTALL_EXAMPLES]/designer/customwidgetplugin
    INSTALLS += target sources
    but the problem still happen!

  6. #6
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: Custom Plugin problem to build

    hm, ... is this missing #include <QtPlugin> ?
    Last edited by janus; 21st December 2008 at 12:50.

  7. #7
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom Plugin problem to build

    I don't think the problem is with this class!
    But here is the class source:

    Qt Code:
    1. #ifndef SPINVIEW_H
    2. #define SPINVIEW_H
    3.  
    4. #include <QSpinBox>
    5. #include "View.h"
    6.  
    7. class SpinView : public QSpinBox, public View {
    8. Q_OBJECT
    9.  
    10. public:
    11. SpinView(QObject *parent=0);
    12. void update(Event e);
    13. };
    14.  
    15. #endif
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "SpinView.h"
    2.  
    3. SpinView::SpinView(QObject *parent){
    4. }
    5.  
    6. void SpinView::update(Event e){
    7. this->setValue(model->getValue());
    8. }
    To copy to clipboard, switch view to plain text mode 

    How can you see, this plugin depends of others source files.

    If you prefer I can send to your e-mail the sources!
    Just give me your e-mail.

  8. #8
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: Custom Plugin problem to build

    What about the qtplugin include?

  9. #9
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom Plugin problem to build

    Nice!!

    I forgot it!
    Now it's showing another problem!!

    But this problem is with my source!!
    Thanks

    If I have another problem I'll ask you again!!

  10. #10
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom Plugin problem to build

    Finally I build it...


    BUT

    When I open designer my plugin isn't shown!!


    I installed the plugin in $QTDIR/plugin/designer/

    I did something wrong??

  11. #11
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: Custom Plugin problem to build

    Hi, you can take a lock in the disigner menu if the plugin was loaded with an error. I had the same problem because i installed the debug version instead ofthe release version.

Similar Threads

  1. Replies: 3
    Last Post: 12th April 2006, 08:20
  2. Problem reimplementing QSpinBox in a custom widget
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 30th March 2006, 08:12
  3. Problem with custom widget
    By jnana in forum Qt Programming
    Replies: 3
    Last Post: 15th March 2006, 11:55
  4. Replies: 16
    Last Post: 7th March 2006, 15:57
  5. Replies: 7
    Last Post: 3rd February 2006, 10:20

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.