Results 1 to 5 of 5

Thread: How signal-slot works across DLL and application???

  1. #1
    Join Date
    Dec 2006
    Posts
    103
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Question How signal-slot works across DLL and application???

    Hi all,
    i want to define a slot in a DLL and a signal in the application where i am using this dll and want to connect this signal-slot in a class of application by creating obj of the class defined in DLL(who has slot defined).
    when i compile i get the following error :
    debug\moc_testlib.cpp:39: error: definition of static data member 'TestLib::staticMetaObject' of dllimport'd class
    debug\moc_testlib.cpp:39: warning: 'TestLib::staticMetaObject' defined locally after being referenced with dllimport linkage
    Can any one help me and tell me that where i am missing???
    my moc_testlib.cpp is as follows :
    Qt Code:
    1. #include "../../lib/testlib.h"
    2. #if !defined(Q_MOC_OUTPUT_REVISION)
    3. #error "The header file 'testlib.h' doesn't include <QObject>."
    4. #elif Q_MOC_OUTPUT_REVISION != 59
    5. #error "This file was generated using the moc from 4.2.2. It"
    6. #error "cannot be used with the include files from this version of Qt."
    7. #error "(The moc has changed too much.)"
    8. #endif
    9. static const uint qt_meta_data_TestLib[] = {
    10.  
    11. // content:
    12. 1, // revision
    13. 0, // classname
    14. 0, 0, // classinfo
    15. 1, 10, // methods
    16. 0, 0, // properties
    17. 0, 0, // enums/sets
    18.  
    19. // slots: signature, parameters, type, tag, flags
    20. 9, 8, 8, 8, 0x08,
    21.  
    22. 0 // eod
    23. };
    24.  
    25. static const char qt_meta_stringdata_TestLib[] = {
    26. "TestLib\0\0slot1()\0"
    27. };
    28.  
    29. const QMetaObject TestLib::staticMetaObject = {
    30. { &QWidget::staticMetaObject, qt_meta_stringdata_TestLib,
    31. qt_meta_data_TestLib, 0 }
    32. };
    33.  
    34. const QMetaObject *TestLib::metaObject() const
    35. {
    36. return &staticMetaObject;
    37. }
    38.  
    39. void *TestLib::qt_metacast(const char *_clname)
    40. {
    41. if (!_clname) return 0;
    42. if (!strcmp(_clname, qt_meta_stringdata_TestLib))
    43. return static_cast<void*>(const_cast<TestLib*>(this));
    44. return QWidget::qt_metacast(_clname);
    45. }
    46.  
    47. int TestLib::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
    48. {
    49. _id = QWidget::qt_metacall(_c, _id, _a);
    50. if (_id < 0)
    51. return _id;
    52. if (_c == QMetaObject::InvokeMetaMethod) {
    53. switch (_id) {
    54. case 0: slot1(); break;
    55. }
    56. _id -= 1;
    57. }
    58. return _id;
    59. }
    To copy to clipboard, switch view to plain text mode 

    Thanks
    Shuchi
    I worked on windows Xp with Qt 4.2.2(Open Source Version) and MinGw
    now i am trying the same things on Fedora Core 5 (linux-gcc) and Qt 4.2.2 open source edition.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How signal-slot works across DLL and application???

    I can't help you with the error, but why don't you move the slot in the main app and when it is called, just call the corresponding method in the dll object? Should work fine...

    Regards

  3. #3
    Join Date
    Dec 2006
    Posts
    103
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How signal-slot works across DLL and application???

    Quote Originally Posted by marcel View Post
    I can't help you with the error, but why don't you move the slot in the main app and when it is called, just call the corresponding method in the dll object? Should work fine...

    Regards
    Thanks, and yes this can be a solution but if i want to check how signal and slot can be connected when one is in a DLL and other in an apllication, then how to do it.
    I worked on windows Xp with Qt 4.2.2(Open Source Version) and MinGw
    now i am trying the same things on Fedora Core 5 (linux-gcc) and Qt 4.2.2 open source edition.

  4. #4
    Join Date
    Dec 2006
    Posts
    103
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: How signal-slot works across DLL and application???

    Hi all,
    I am back once again as i really need help. Can anyone help me in this signal-slot problem between DLL and application.
    Thanks in advance.
    I worked on windows Xp with Qt 4.2.2(Open Source Version) and MinGw
    now i am trying the same things on Fedora Core 5 (linux-gcc) and Qt 4.2.2 open source edition.

  5. #5
    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: How signal-slot works across DLL and application???

    Are the exports/imports defined correctly? Could you create a minimal example reproducing the problem?
    J-P Nurmi

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
  •  
Qt is a trademark of The Qt Company.