Results 1 to 1 of 1

Thread: Signals in libraries

  1. #1
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Signals in libraries

    Hi,


    edit: dont bother, solved


    my project consists of two parts: One GUI-project and one library that exposes an API consumed by the GUI app. Both of them are qtcreator projects. Everything works fine without signals and slots.


    But now I have added a class with a signal to the library-project. The signal is emitted in one of the APIs exposed to the GUI. But even when there are no slots connected to that signal, my Application craps out and crashes!
    Yes, the app launches but when I press the button that triggers the signal, it executes right up to the "emit" and then crashes at runtime!



    .../qtgui: symbol lookup error: .../qtgui/../core/libcore.so.1: undefined symbol: _ZN5xtest4testE7myevent

    Here is the code, some_exposed_api() is called from the GUI:

    Qt Code:
    1. bool LIBLIBSHARED_EXPORT some_exposed_api()
    2. {
    3. xtest tt;
    4. tt.test_emit();
    5. }
    6.  
    7. ...
    8.  
    9. class myevent
    10. {
    11. public:
    12. myevent() = default;
    13.  
    14. uint xyz = 0;
    15.  
    16. };
    17. Q_DECLARE_METATYPE(myevent);
    18.  
    19.  
    20. class xtest : public QObject
    21. {
    22. public:
    23. xtest()
    24. {
    25. qRegisterMetaType<myevent>("myevent");
    26. }
    27.  
    28. void test_emit()
    29. {
    30. myevent x;
    31. emit test(x); //crash!
    32. }
    33. signals:
    34. void test(myevent x);
    35. };
    To copy to clipboard, switch view to plain text mode 



    Why does it crash? I dont get it. It's all loaded into one process at runtime.

    Alright, of course minutes after posting I realize the mistake: the goddamn Q_OBJECT macro was missing .. wasnt I supposed to get a big fat warning in qtcreator when that happens ...
    Last edited by tuli; 17th October 2018 at 08:50.

Similar Threads

  1. Release libraries bigger than debug libraries
    By JPNaude in forum Qt Programming
    Replies: 5
    Last Post: 4th April 2013, 09:30
  2. Replies: 4
    Last Post: 5th November 2011, 02:38
  3. Replies: 6
    Last Post: 29th April 2011, 16:22
  4. Replies: 1
    Last Post: 24th October 2010, 12:09
  5. QThread and signals (linux/UNIX signals not Qt Signals)
    By Micawber in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2007, 23:18

Tags for this Thread

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.