Results 1 to 2 of 2

Thread: Problem in QObject::connect( ... ) with smart_ptr ( Boost )

  1. #1
    Join Date
    Oct 2007
    Posts
    21
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Problem in QObject::connect( ... ) with smart_ptr ( Boost )

    Hi,

    I have used QObject::connect( ... ) with smart_ptr but as per the signature of connect( ... ), strictly we have to use class object derived from QObject.

    this below code will work fine..!!
    Qt Code:
    1. class A:public QObject{ ... }
    2. class B:public QObject{ ... }
    3.  
    4. class c:public QObject
    5. {
    6.  
    7. c::c()
    8. {
    9. A *a = new A();
    10. B *b = new B();
    11.  
    12. QObject::connect( a, SIGNAL( funA() ), b, SLOT( funB() ) );
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

    but when convert *a and *b to smart_ptr<a> and smart_ptr<b> it don't work properly..!!
    the signal and slot don't connect..

    So can anybody help me in solving this error, any one who is using smart_ptr (boost) with Qt, give me some suggestion to go ahead .!!

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem in QObject::connect( ... ) with smart_ptr ( Boost )

    I am not quite sure about your problem. How about
    Qt Code:
    1. c::c()
    2. {
    3. boost::shared_ptr<A> a(new A);
    4. boost::shared_ptr<B> b(new B);
    5. QObject::connect( a.get(), SIGNAL( funA() ), b.get(), SLOT( funB() ) );
    6. }
    To copy to clipboard, switch view to plain text mode 

    HTH

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.