Results 1 to 4 of 4

Thread: Can i call a Signal normally?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2012
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Can i call a Signal normally?

    Like slots can be called normally, Can I call a Signal normally?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: Can i call a Signal normally?

    For what? What do you expect by calling a signal normally? A signal typically has no definition.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Can i call a Signal normally?

    Moc generates an implementation that is just a wrapper around QMetaObject::activate() and the "emit" or "Q_EMIT" pseudo-keyword is #defined away (see src/corelib/kernel/qobjectdefs.h). So, in short, you are always calling the signal directly.

    The original question could have been answered in about 5 minutes by writing a quick test program to try it.

    The only reason I could imagine you would care is if you wanted to use the signal as a traditional callback function, using std::tr1::function and ::bind for example. The "emit" keyword doesn't fit there.
    Last edited by ChrisW67; 29th May 2012 at 23:14.

  4. #4
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    29
    Thanked 50 Times in 47 Posts

    Wink Re: Can i call a Signal normally?

    You can call signal or slot like this---->


    One signal can be connected to many slots:
    Qt Code:
    1. connect(slider, SIGNAL(valueChanged(int)),
    2. spinBox, SLOT(setValue(int)));
    3. connect(slider, SIGNAL(valueChanged(int)),
    4. this, SLOT(updateStatusBarIndicator(int)));
    To copy to clipboard, switch view to plain text mode 

    Many signals can be connected to the same slot:
    Qt Code:
    1. connect(lcd, SIGNAL(overflow()),
    2. this, SLOT(handleMathError()));
    3. connect(calculator, SIGNAL(divisionByZero()),
    4. this, SLOT(handleMathError()));
    To copy to clipboard, switch view to plain text mode 

    A signal can be connected to another signal:
    Qt Code:
    1. connect(lineEdit, SIGNAL(textChanged(const QString &)),
    2. this, SIGNAL(updateRecord(const QString &)));
    To copy to clipboard, switch view to plain text mode 


    When the first signal is emitted, the second signal is emitted as well.
    Apart from that, signal–signal connections are indistinguishable from
    signal–slot connections.

Similar Threads

  1. QAction, triggered signal dont call a slot
    By kaszewczyk in forum Newbie
    Replies: 6
    Last Post: 5th October 2010, 21:30
  2. Replies: 1
    Last Post: 12th August 2010, 19:21
  3. toggled(bool) signal does not call my slot?
    By Asperamanca in forum Newbie
    Replies: 6
    Last Post: 22nd July 2010, 09:54
  4. Signal/slot or direct method call within a class
    By mike_the_tv in forum Newbie
    Replies: 6
    Last Post: 11th March 2010, 18:49
  5. Doxgen call graphs also for signal-slot calls?
    By zavulon in forum Qt Programming
    Replies: 0
    Last Post: 25th September 2008, 15:29

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
  •  
Qt is a trademark of The Qt Company.