Results 1 to 3 of 3

Thread: QtPlugin compile issue

  1. #1
    Join Date
    Aug 2006
    Posts
    26
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QtPlugin compile issue

    Hello everyone,

    I am trying to create a plugin that either sets up a widget with controls or returns a QWigdet that will become a child widget of a parent. Bascially I am trying to use QtPlugin to create a MDI app and each plugin will provide a different view.

    I am using Qt 4.2.2 Windows Open Source with MinGW as the compiler.

    The issue I am running into is I keep getting the following error when trying to compile my test plugin:

    moc_myplugin.cpp: undefined reference to 'vtable for MyPluginInterface'

    When I take out the setupWidget function everthing works fine and I can even call the gethello function from a test app from the compiled plugin dll.

    Thank you in advance for any help .


    - Chris


    Here is the code for my plugin and interface:

    //-----------------------------------
    // interface.h
    //-----------------------------------

    #ifndef INTERFACES_H
    #define INTERFACES_H

    class QString;
    class QWidget;

    class MyPluginInterface
    {
    public:
    virtual ~MyPluginInterface() {}
    virtual QString gethello() const = 0;
    virtual void createWidget(QWidget *parent = 0);
    };

    Q_DECLARE_INTERFACE(MyPluginInterface, "com.MyPluginInterface/1.0")

    #endif //INTERFACES_H





    //-----------------------------------
    // myplugin.h
    //-----------------------------------

    #ifndef MYPLUGIN_H
    #define MYPLUGIN_H

    #include <QObject>
    #include <QString>
    #include <QWidget>
    #include <QPushButton>
    #include <QtGui>

    #include "interfaces.h"

    class MyPlugin : public QObject, public MyPluginInterface
    {
    Q_OBJECT
    Q_INTERFACES(MyPluginInterface)

    public:
    // MyPluginInterface
    MyPlugin(){};
    ~MyPlugin(){};
    QString gethello() const;
    void createWidget(QWidget *parent);
    };

    #endif //MYPLUGIN_H




    //-----------------------------------
    // myplugin.cpp
    //-----------------------------------

    #include "myplugin.h"

    QString MyPlugin::gethello() const
    {
    return "Hello World!";
    }

    void MyPlugin::createWidget(QWidget *parent)
    {

    }
    Q_EXPORT_PLUGIN2(myplugin, MyPlugin)

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtPlugin compile issue

    "createWidget" is not declared as pure virtual (=0).

  3. #3
    Join Date
    Aug 2006
    Posts
    26
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtPlugin compile issue

    Ah oops. That fixed it, thanks for the help. It's amazing the response time you guys have on this forum.

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.