Results 1 to 2 of 2

Thread: signals and slots in plugins

  1. #1

    Default signals and slots in plugins

    Hi,

    i'm trying to use signals and slots in plugins that will be loaded at runtime. But the plugins fails to load and i get this message:
    "QLibrary::load_sys: Cannot load libvectorplugin.so.1.0.0 (libvectorplugin.so.1.0.0: undefined symbol: _ZN10App4Calcs11ICalculator10metaObjectEv)"
    The plugin contains implementations of the following interfaces:
    Qt Code:
    1. class ICalculator : public QObject
    2. {
    3. Q_OBJECT
    4. public:
    5. IView * createView() = 0;
    6. (...)
    7. signals:
    8. void calculationDone();
    9. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. class IView : public QObject
    2. {
    3. Q_OBJECT
    4. public:
    5. (..)
    6. public slots:
    7. virtual void renderData() =0;
    8. };
    To copy to clipboard, switch view to plain text mode 

    and finally the plugin interface (the implementation of this inteface will be exported as a plugin):

    Qt Code:
    1. class IPlugin
    2. {
    3. public:
    4. ICalculator* createCalculator() = 0;
    5. };
    6. Q_DECLARE_INTERFACE(App::Calcs::IPlugin ,"IPlugin");
    To copy to clipboard, switch view to plain text mode 

    Implementation inside the plugin:
    Qt Code:
    1. class VectorView : public IView
    2. {
    3. Q_OBJECT
    4. public slots:
    5. virtual void renderData()
    6. {
    7. (..)
    8. }
    9. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. class VectorCalculator : ICalculator
    2. {
    3. Q_OBJECT
    4. public:
    5. virtual void calculate()
    6. {
    7. (...)
    8. emit calculationDone();
    9. }
    10. };
    To copy to clipboard, switch view to plain text mode 

    the qmake file:
    Qt Code:
    1. TEMPLATE = lib
    2. CONFIG += warn_on \
    3. thread \
    4. qt
    5. TARGET = ../bin/vectorcalculator
    6.  
    7. QT += gui opengl
    8. HEADERS += vectorcalculator.h
    9. vectorview.h \
    10. vectorplugin.h
    11.  
    12. SOURCES += vectorcalculator.cpp vectorview.cpp vectorplugin.cpp
    To copy to clipboard, switch view to plain text mode 
    The compilation works fine. Why do i get this linker error at runtime?

    thanks in advance!

  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: signals and slots in plugins

    Interfaces can't be QObjects. The interface should contain virtual methods that will be implemented by each plugin. Only the plugin itself should inherit QObject and you can define signals and slots there. Then you can ask the plugin for available signals and slots using the meta object.

Similar Threads

  1. Signals and Slots question
    By Thoosle in forum Qt Programming
    Replies: 5
    Last Post: 5th December 2006, 00:24
  2. Nested signals and slots
    By vishva in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2006, 09:47
  3. Signals and Slots in dll
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 29th March 2006, 08:12
  4. Order of signals and slots
    By Morea in forum Newbie
    Replies: 1
    Last Post: 26th February 2006, 22:09
  5. Problem with Signals and Slots
    By Kapil in forum Newbie
    Replies: 11
    Last Post: 15th February 2006, 11:35

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.