Results 1 to 3 of 3

Thread: signal & slot

  1. #1
    Join Date
    Sep 2012
    Location
    Iran, Tehran
    Posts
    76
    Thanks
    17
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Question signal & slot

    Is there a way to stop execution of a slot/function when a signal is emitted?

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: signal & slot

    You have to tell more information about what are you trying to do, so generic answer is you can disconnect the signal-slot connection or use return/exceptions if the condition to "stop" the slot execution is true.

  3. #3
    Join Date
    Sep 2012
    Location
    Iran, Tehran
    Posts
    76
    Thanks
    17
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: signal & slot

    I needed to check for a condition in a loop, the condition was a change in the range of a QScrollBar. So I wrote something like this pseudo-code:
    Qt Code:
    1. int max = QScrollBar::maximum();
    2.  
    3. while (max == QScrollBar::maximum())
    4. {
    5. do something;
    6. }
    To copy to clipboard, switch view to plain text mode 

    Then it crossed my mind to use QAbstractSlider::rangeChanged signal to control the execution of the loop if it is possible. This signal reports what I am looking for.

    By stopping execution of a slot/function I mean exiting from it in the middle of execution of the slot/function.

  4. The following user says thank you to Ashkan_s for this useful post:


Similar Threads

  1. Replies: 2
    Last Post: 3rd May 2011, 20:22
  2. Signal connected to slot (or signal)
    By Althor in forum Newbie
    Replies: 2
    Last Post: 6th July 2010, 10:00
  3. Signal and slot
    By jayreddy in forum Qt Programming
    Replies: 12
    Last Post: 15th December 2009, 05:05
  4. Replies: 1
    Last Post: 8th November 2007, 17:11
  5. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 18: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
  •  
Qt is a trademark of The Qt Company.