Results 1 to 5 of 5

Thread: Passing a pointer in Signal/Slot Connection

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    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: Passing a pointer in Signal/Slot Connection

    Quote Originally Posted by momesana View Post
    maybe you should try dynamic_cast<> and only access the data if the pointer to the casted object is valid. At least, that is the safest way to do a cast.

    Qt Code:
    1. void DMXTable::SLOT_AllDMXPropsReceived( unsigned long u4member, void* pData )
    2. {
    3. CDMXGateway* pNode = dynamic_cast<CDMXGateway*>( pData );
    4. if (pNode) {
    5. // Access data & crash
    6. SetDeviceName( pNode->GetDeviceName() );
    7. SetIPAddr( pNode->GetIPAddr() );
    8. ...
    9. }
    To copy to clipboard, switch view to plain text mode 
    Are you advising him to patch his code?

    @mclark: Could we see the code from the thread where you emit the signal?
    BTW, you shouldn't use void*, but register your custom type with qRegisterMetaType.
    And if you're using visual studio, why in the world won't you debug the application? You can't get a debugger better than that.
    Last edited by marcel; 6th November 2007 at 17:32.

Similar Threads

  1. Replies: 1
    Last Post: 4th November 2006, 06:53
  2. 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
  •  
Qt is a trademark of The Qt Company.