Results 1 to 20 of 21

Thread: qRegisterMetaType- reference as argument in connect throwing run time error

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,233
    Thanks
    303
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qRegisterMetaType- reference as argument in connect throwing run time error

    Then you should probably not have used a local variable definition.
    @prasad_N:
    Or at least written it as a commented-out line, with an explanation that "obj" is a class member variable. How are we to understand that when you write it as you did, you weren't posting your actual code? A lot of the discussion here was based on your incorrect posting, and it could have been avoided if you had posted the actual code in the first place.

    C++ programmers can also use pointers and can use references for the special case where the alias can be initialized with the address of the object, e.g. passing a reference to a constructor, storing it in a reference member.
    And this has the added benefit over storing a pointer member variable in that you are absolutely assured that the member variable is a valid reference to an object instance, whereas anything can be assigned to a pointer member, including nothing.

  2. #2
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qRegisterMetaType- reference as argument in connect throwing run time error

    Quote Originally Posted by d_stranz View Post
    A lot of the discussion here was based on your incorrect posting, and it could have been avoided if you had posted the actual code in the first place.
    There was a mistake & people are over emphasizing on that rather than a actual question, Anyhow I will take care from next time while posting.


    Quote Originally Posted by anda_skoa View Post
    It depends on your requirements.
    If you want the slot to execute in the context of the emitter thread, use a direct connection.
    If you want to use the signal/slot bridge as a mean to conveniently copy data between threads, use a queued connection.
    _
    None of them are not my requirements. As per my requirement & Replay's from you guys I think there is no solution for this at least for now (passing reference across threads if it it is queued connection).
    Thanks :-)

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qRegisterMetaType- reference as argument in connect throwing run time error

    Yes, the only reference that can be stored is a pointer.

    Cheers.
    _

Similar Threads

  1. Replies: 0
    Last Post: 19th January 2012, 15:52
  2. Replies: 2
    Last Post: 9th May 2011, 10:38
  3. Replies: 6
    Last Post: 9th April 2011, 19:23
  4. qRegisterMetaType - problems with connect()
    By Macok in forum Qt Programming
    Replies: 1
    Last Post: 5th March 2009, 22:55
  5. Replies: 2
    Last Post: 8th October 2007, 15:02

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.