Results 1 to 4 of 4

Thread: send own class reference throught signal

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default send own class reference throught signal

    Hi,

    I have a own class that I need to emit using a signal. The problem is:

    Qt Code:
    1. class classA
    2. classA::classA()
    3. {
    4.  
    5. }
    6. public slots:
    7. void aSlot(myClass&);
    8.  
    9. class classB: public classA
    10. classB::classB()
    11. {
    12. bool bC = connect(pClassC,SIGNAL(aSignal(myClass&)),this,SLOT(aSlot(myClass&));
    13. //This returns me "true"
    14. };
    15. classC* pClassC;
    To copy to clipboard, switch view to plain text mode 

    classA is a base Class. Has the slot to be called.
    classB is derived from classA. Conects the classC signal with parent slot.
    classC is a class that do something and emits a signal.

    I had this working by passing the objects as value, but now, passing them by reference, the slot is not called.

    Any idea what is happening?

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: send own class reference throught signal

    Hi,

    I'm getting this:
    Qt Code:
    1. Make sure 'myClass&' is registered using qRegisterMetaType().)
    To copy to clipboard, switch view to plain text mode 


    When I try to register it I'm getting this error when compiling:
    Qt Code:
    1. c:\Qt\4.3.0\src\corelib\kernel\qmetatype.h(104): error C2558: class 'myClass' : no hay un constructor de copias disponible o éste se declaró como 'explicit'
    2.  
    3. in english maybe something like this:
    4. c:\Qt\4.3.0\src\corelib\kernel\qmetatype.h(104): error C2558: class 'myClass' : there is not a copy constructor or this have been declared as 'explicit'
    To copy to clipboard, switch view to plain text mode 

    Thanks,
    Òscar Llarch i Galán

  3. #3
    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: send own class reference throught signal

    Are you sure you don't want to pass it as const reference?
    J-P Nurmi

  4. #4
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: send own class reference throught signal

    Hi,

    I just added "const" to copy constructor and it works.

    Are you sure you don't want to pass it as const reference?
    How to do this and what is the difference?

    Thanks,
    Òscar Llarch i Galán

Similar Threads

  1. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  2. MS Sql native driver??
    By LordQt in forum Qt Programming
    Replies: 4
    Last Post: 9th October 2007, 13:41
  3. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 14:28
  4. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 19:15
  5. Strange error while using Q3Canvas
    By Kapil in forum Newbie
    Replies: 13
    Last Post: 15th June 2006, 19:36

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.