Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Blocking a signal

Blocking a signal

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Naveen_DN Offline
    Naveen_DN Offline
    Naveen_D
    wrote on last edited by Naveen_D
    #1

    Hi all,

    Is there any way to block a signal from emitting?
    For example, i have a signal defined in my program, which i am emitting in a function like

    my class:: func xyz(){
    emit abcsignal();
    }
    I am emitting signal based on few conditions, for some reason in one condition i don't want it to emit,
    any way to prevent abcsignal from emitting ?

    Thank you

    Naveen_D

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Just use a normal if ?

      my class:: func xyz(){
      if ( condition )
      emit abcsignal();
      else
      qDebug() << "signal not emitted";
      }

      Naveen_DN 1 Reply Last reply
      6
      • Cobra91151C Offline
        Cobra91151C Offline
        Cobra91151
        wrote on last edited by
        #3

        Also you can use function blockSignals(true) to prevent signal from emiting.

        More information - http://doc.qt.io/qt-4.8/qobject.html#blockSignals

        1 Reply Last reply
        3
        • mrjjM mrjj

          Hi
          Just use a normal if ?

          my class:: func xyz(){
          if ( condition )
          emit abcsignal();
          else
          qDebug() << "signal not emitted";
          }

          Naveen_DN Offline
          Naveen_DN Offline
          Naveen_D
          wrote on last edited by
          #4

          @mrjj thank you for the reply... ya i have used if condition.

          Naveen_D

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved