Results 1 to 6 of 6

Thread: Testing a custom Plugin

  1. #1
    Join Date
    Apr 2006
    Posts
    1
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Testing a custom Plugin

    I've created a custom plugin and put this on my designer widget box, after I created a new form (widget) for an application to test my plugin...
    I just drop my custom plugin in a form widget and wrote the main.cpp file

    Qt Code:
    1. #include <QApplication>
    2. #include <QDialog>
    3.  
    4. #include "ui_form.h"
    5.  
    6. int main(int argc,char *argv[]) {
    7.  
    8. QApplication app(argc,argv);
    9. QDialog* tela = new QDialog;
    10. Ui::Form ui;
    11. ui.setupUi(tela);
    12. tela->show();
    13. return app.exec();
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 

    But when I compile the source code, I got the follwing message:

    g++ -c -pipe -march=pentium4 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/doc/qt-4.1.1/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o main.o main.cpp
    g++ -o teste_plugin_2 main.o -L/usr/lib/qt4 -lQtGui -L/usr/lib/mysql -L/usr/lib/qt4 -L/usr/lib -laudio -lXt -lpng -lSM -lICE -lXi -lXrender -lXrandr -lXcursor -lfreetype -lfontconfig -lXext -lX11 -lQtCore -lz -lm -ldl -lpthread
    main.o: In function `main':
    main.cpp:(.text+0x1a7): undefined reference to `MyButtons::MyButtons(QWidget*)'
    collect2: ld returned 1 exit status
    make: ** [teste_plugin_2] Erro 1

    Here is my class definition (because I'm using a plugin I have to files mybuttons.h and mybuttonplugin.h, but I think the problem is on mybutton.h)

    Qt Code:
    1. #ifndef MYBUTTONS_H
    2. #define MYBUTTONS_H
    3.  
    4. #include <QPushButton>
    5. #include <QHBoxLayout>
    6. #include <QWidget>
    7. #include <QtDesigner/QDesignerExportWidget>
    8.  
    9. class QDESIGNER_WIDGET_EXPORT MyButtons : public QWidget {
    10.  
    11. Q_OBJECT
    12. public:
    13. MyButtons(QWidget *parent=0);
    14. protected:
    15. void setB1Text(const QString&);
    16. void setB2Text(const QString&);
    17. const QString getB1Text() const;
    18. const QString getB2Text() const;
    19. signals:
    20. void B1Clicked();
    21. void B2Clicked();
    22. private:
    23. QHBoxLayout* layout;
    24. };
    25. #endif
    To copy to clipboard, switch view to plain text mode 

    And the constructor implementation

    Qt Code:
    1. MyButtons::MyButtons(QWidget* parent) : QWidget(parent) {
    2.  
    3. B1 = new QPushButton();
    4. B2 = new QPushButton();
    5. layout = new QHBoxLayout(this);
    6.  
    7. layout->addWidget(B1);
    8. layout->addWidget(B2);
    9.  
    10. connect (B1, SIGNAL(clicked()), this, SIGNAL(B1Clicked()));
    11. connect (B2, SIGNAL(clicked()), this, SIGNAL(B2Clicked()));
    12. }
    To copy to clipboard, switch view to plain text mode 

    I'm using qt 4.1.1 (gcc 3.4.0) on a x86 machine.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Testing a custom Plugin

    You must link your application with the plugin (or at least the implementation of the MyButtons class).

  3. The following user says thank you to jacek for this useful post:

    maluta (1st May 2006)

  4. #3
    Join Date
    Jan 2006
    Posts
    18
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Testing a custom Plugin

    Can you provide an example of what is meant by:

    You must link your application with the plugin (or at least the implementation of the MyButtons class).
    I am having the same problem as Maluta.

    Thanks,
    Royce

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Testing a custom Plugin

    Quote Originally Posted by Royceybaby View Post
    Can you provide an example of what is meant by [...]
    If you use qmake, it should be:
    LIBS += -lmybuttonplugin
    or
    SOURCES += mybutton.cpp
    HEADERS += mybutton.h
    depending on what you want to achieve.

  6. #5
    Join Date
    Jan 2006
    Posts
    18
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Testing a custom Plugin

    I have subclassed QTableWidget and have made a designer plugin called EnhancedTableWidget.

    I have successfully compiled the designer plugin and copied the two files

    enhancedtablewidget.dll
    libenhancedtablewidget.a

    to the $QTDIR\plugins\designer directory.

    I can create a new form with my new widget on it.

    When I try and compile a simple example using Maluta's main.cpp I get the following error:

    release\main.o(.text+0x267):main.cpp: undefined reference to `EnhancedTableWidget::EnhancedTableWidget(QWidget* )'

    Here is my current .pro file

    Qt Code:
    1. TEMPLATE = app
    2. QT += sql
    3. TARGET =
    4. DEPENDPATH += .
    5. INCLUDEPATH += .
    6.  
    7. # Input
    8. HEADERS += enhancedtablewidget.h
    9. FORMS += form.ui
    10. SOURCES += main.cpp
    11. LIBS += C:/Devel/Qt/4.2.0/plugins/designer/libenhancedtablewidgetplugin.a
    To copy to clipboard, switch view to plain text mode 

    I am using Qt4.2.0 on Windows XP with mingw.

    Thanks,
    Royce

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Testing a custom Plugin

    Quote Originally Posted by Royceybaby View Post
    I am using Qt4.2.0 on Windows XP with mingw.
    Since you use windows, make sure you have proper __declspec directive between "class" and "EnhancedTableWidget".

  8. The following user says thank you to jacek for this useful post:

    Royceybaby (6th November 2006)

Similar Threads

  1. problem loading custom plugin on Qt Designer 4
    By raman_31181 in forum Qt Tools
    Replies: 18
    Last Post: 26th September 2008, 10:42
  2. custom plugin load fails...
    By raman_31181 in forum Qt Tools
    Replies: 3
    Last Post: 3rd July 2008, 10:37
  3. QPluginLoader not recognizing a plugin
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 15:13
  4. Replies: 2
    Last Post: 25th August 2006, 12:35
  5. Custom plugin for a layout
    By cocheci in forum Qt Tools
    Replies: 2
    Last Post: 12th June 2006, 19:36

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.