Results 1 to 3 of 3

Thread: SIGNAL/SLOT - Object scope?

  1. #1
    Join Date
    Jan 2012
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default SIGNAL/SLOT - Object scope?

    I was curious what is the scope of an object, if I do that.

    Qt Code:
    1. void myMethod() {
    2. Object o;
    3. emit MySignal(o);
    To copy to clipboard, switch view to plain text mode 

    If I transfer the object to another thread, what happens to the object scope? o is allocated on stack.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: SIGNAL/SLOT - Object scope?

    The object always goes out of scope when the function returns. The signal carries a copy of the object in case of a cross-thread emission and a copy or a cost or non-const reference in case of a direct call.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2012
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SIGNAL/SLOT - Object scope?

    Quote Originally Posted by wysota View Post
    The object always goes out of scope when the function returns. The signal carries a copy of the object in case of a cross-thread emission and a copy or a cost or non-const reference in case of a direct call.
    Thanks!

Similar Threads

  1. Replies: 2
    Last Post: 3rd May 2011, 21:22
  2. Connect signal from base to slot of sub-sub-object
    By donglebob in forum Qt Programming
    Replies: 15
    Last Post: 30th October 2008, 20:54
  3. Signal to specific object slot
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 27th December 2007, 16:51
  4. Signal-Slot, object instances
    By ct in forum Qt Programming
    Replies: 3
    Last Post: 16th February 2006, 20:08
  5. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 19:52

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.