Results 1 to 5 of 5

Thread: Signal/Slot methods

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2007
    Posts
    56
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Signal/Slot methods

    Thank you for that insight Marcel. It saved me a lot of digging.

    I take it from your explanation of how it works, that it is not possible to have user specified code as a signal method. As in...

    Qt Code:
    1. class fiddlestix {
    2. Q_OBJECT
    3.  
    4. public signals:
    5. void doThisWhenISignal( int foo );
    6.  
    7. };
    8.  
    9. fiddlestix::doThisWhenISignal( int foo )
    10. {
    11.  
    12. foo += 53;
    13.  
    14. }
    To copy to clipboard, switch view to plain text mode 

    In other words, I cannot define a section of code that I wish to be executed every time I emit the signal that does something _before_ Qt starts operating on it?

  2. #2
    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: Signal/Slot methods

    No, you cannot do that.
    At most you can connect another slot to that signal, but before you connect the actual slot.
    The first slot will get executed before the second. This is if you want to do something before the second slot is executed.
    The connect order dictates the slot execution order for direct connections.

    If you want to do something before actually the signal is emitted, you have only one chance: if you emit the signal yourself, i.e. by calling (emit signal). Then you could put some code before the emit statement.

    EDIT: when declaring signals, you must not give them a visibility modifier( public, protected, private ). Just signals:. This is opposed to slots, where you always have to specify their visibility.

    Regards

  3. #3
    Join Date
    Jun 2007
    Posts
    56
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Signal/Slot methods

    Got it. Thanks Marcel!

    Also I take your point re: visibility of signals vs. slots. Good insight.

Similar Threads

  1. How to access OCX methods and events
    By joy in forum Qt Programming
    Replies: 4
    Last Post: 1st May 2018, 16:37
  2. What argument types for Signal/Slot?
    By DPinLV in forum Qt Programming
    Replies: 5
    Last Post: 2nd August 2006, 19:08
  3. What if not Signal/Slot
    By munna in forum General Discussion
    Replies: 2
    Last Post: 26th May 2006, 06:48
  4. Replies: 4
    Last Post: 23rd January 2006, 16:51
  5. What's the relationship between signal/slot and event?
    By twosnowman in forum Qt Programming
    Replies: 4
    Last Post: 11th January 2006, 17:13

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.