Results 1 to 10 of 10

Thread: emit signal from a slot?

  1. #1
    Join Date
    Jun 2010
    Posts
    7
    Qt products
    Qt3 Qt4

    Default emit signal from a slot?

    Is it legal to emit a signal in a slot?

    I am trying to emit a signal in a slot, and want to trigger another slot. The intended slot does not seems called. Wondering if it's legal to do that?

    Thanks,

  2. #2
    Join Date
    Jun 2010
    Posts
    18
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: emit signal from a slot?

    I have no trouble with it. You may want to be more clear by posting the nw code.

  3. #3
    Join Date
    Mar 2009
    Location
    Tennessee, US
    Posts
    41
    Thanks
    3
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: emit signal from a slot?

    I have no problem either. This is legal.
    Amos
    Qt Programmer Extraordinaire

    Current Work:
    Ripxx Sports Measurement Device - www.ripxx.com
    (Featured in MYTHBUSTERS on 2010-05-19 in S08E08)

  4. #4
    Join Date
    Jun 2010
    Posts
    7
    Qt products
    Qt3 Qt4

    Default Re: emit signal from a slot?

    Well, the connect() returned false. signal/slot signatures match.
    rc=connect(p, SIGNAL(status(bool)),
    this, SLOT(handStatus(bool)));

  5. #5
    Join Date
    Jun 2010
    Posts
    23
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: emit signal from a slot?

    If it works for you, you can connect the signal with the other signal.
    Stelios: What the hell are you laughing at?
    Astinos: Well, you had to say it!
    Stelios: What?
    Astinos: "Fight in the shade"!
    -------------------------------------------
    If my answer has helped you, i would appreciate it if you use the thanks button.

  6. #6
    Join Date
    Jun 2010
    Posts
    18
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: emit signal from a slot?

    1. What is p?
    2. Does p have SIGNAL called status?
    3. Use CODE rather than QUOTE around your code.
    Quote Originally Posted by ask8y@yahoo.com View Post
    Well, the connect() returned false. signal/slot signatures match.
    rc=connect(p, SIGNAL(status(bool)),
    this, SLOT(handStatus(bool)));

  7. #7
    Join Date
    Jun 2010
    Posts
    7
    Qt products
    Qt3 Qt4

    Default Re: emit signal from a slot?

    Quote Originally Posted by ask8y@yahoo.com View Post
    Well, the connect() returned false. signal/slot signatures match.
    rc=connect(p, SIGNAL(status(bool)),
    this, SLOT(handStatus(bool)));
    Well, well, well,
    It was the typo, handleStatus instead of handStatus. Nice if it failed at compilation time! It works now.

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

    Default Re: emit signal from a slot?

    It can't fail at compilation time because introspection in Qt is done in run-time and not compile-time. Otherwise many of the features Qt offers couldn't be used.
    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.


  9. #9
    Join Date
    Feb 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: emit signal from a slot?

    qt spits out warnings about connections containing non-existant slots/signals to the console when the program is executed, so if you're using QtCreator, look at the application output panel, otherwise execute it from a console.
    iirc you need to add CONFIG+=console if you're working on windows for that to work.

    cheers,
    thomas

  10. #10
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: emit signal from a slot?

    Quote Originally Posted by ask8y@yahoo.com View Post
    Is it legal to emit a signal in a slot?

    I am trying to emit a signal in a slot, and want to trigger another slot. The intended slot does not seems called. Wondering if it's legal to do that?

    Thanks,
    I'm just going to state the obvious here:
    Keep an eye on infinite loops. Don't emit a signal that eventually calls the slot again. This way you end in an infinite loop.

Similar Threads

  1. Emit signal from thread
    By sisco in forum Newbie
    Replies: 2
    Last Post: 26th November 2009, 13:32
  2. Disabled QSpinBox emit signal?
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 22nd July 2009, 17:42
  3. signal doesnt emit
    By mark2804 in forum Newbie
    Replies: 2
    Last Post: 25th December 2008, 22:36
  4. how to know which button emit the signal?
    By coder1985 in forum Qt Programming
    Replies: 2
    Last Post: 12th January 2008, 14:26
  5. emit a signal
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 27th February 2006, 11:14

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.