Results 1 to 4 of 4

Thread: Signal/Slot connection failing

  1. #1
    Join Date
    May 2010
    Posts
    41
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Signal/Slot connection failing

    Hi,

    I have a class and dll structure similar to the following...

    Specific.dll
    class Form
    - contains a Controller *mController
    - contains a CustomDoubleSpinBox*mCustomDoubleSpinBox

    class Controller
    - has signal MySignal(double,double,double)
    Common.dll
    class CustomDoubleSpinBox
    - derives from QDoubleSpinBox
    - has slot MySlot(double, double, double)


    In the Form class, I create the following connection:
    Qt Code:
    1. connect( mController, SIGNAL(MySignal(double,double,double)), mCustomSpinBox, SLOT(MySlot(double,double,double)));
    To copy to clipboard, switch view to plain text mode 
    This connection fails. The error I get in the output window is:

    Object::connect: No such slot QDoubleSpinBox::MySlot(double,double,double)
    I am able to call the slot function normally, and the slot is a member of CustomDoubleSpinBox, not QDoubleSpinBox as is printed in the output...

    I'm not quite sure why this is happening...perhaps it has to do with the signal and slot being in different DLLs?

    All help is greatly appreciated Thanks!
    Last edited by Polnareff; 15th July 2010 at 19:51.

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Signal/Slot connection failing

    That error is when you run the program?
    Most likely you forgot to declare MySlot(...) with "public slots:" access specifier

  3. #3
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Signal/Slot connection failing

    This would suggest that the custom double spin box doesn't have the slot properly defined. If it was, the name would have ended up in a list of strings during mocing.

    The signal/slot system is basically a nifty way of calling functions. DLL boundaries have no effect on it (Qt does cross dll all the time).
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  4. The following user says thank you to franz for this useful post:

    Polnareff (15th July 2010)

  5. #4
    Join Date
    May 2010
    Posts
    41
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Signal/Slot connection failing

    I did define it with public slots...but franz just made me realize perhaps I needed to re-build my project...and then further made me realize I never added the Q_OBJECT macro to my class

    Thanks for the help!

Similar Threads

  1. Signal and Slot connection not working !!
    By prakash437 in forum Qt Programming
    Replies: 3
    Last Post: 17th May 2010, 10:16
  2. Signal and slot connection graph
    By fahlen in forum General Discussion
    Replies: 4
    Last Post: 27th November 2007, 13:47
  3. Interesting little Segfault w/r to signal/slot connection
    By Hydragyrum in forum Qt Programming
    Replies: 24
    Last Post: 12th September 2006, 19:22
  4. signal slot connection
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 4th July 2006, 13:31
  5. queued signal/slot connection with QList<int>
    By smalls in forum Qt Programming
    Replies: 2
    Last Post: 7th February 2006, 14:32

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.