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. How to cancel pending(unprocessed) emitted signals
Forum Updated to NodeBB v4.3 + New Features

How to cancel pending(unprocessed) emitted signals

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 2.1k 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.
  • F Offline
    F Offline
    foxgod
    wrote on last edited by
    #1

    i have 3 buttons every button is connected by QSIgnalMap;
    connect(button, SIGNAL(pressed()), signalMapper, SLOT(map()),Qt::DirectConnection);
    connect(signalMapper,SIGNAL(mapped(QObject*)),this,SLOT(setBackground(QObject*)),Qt::DirectConnection);

    when i clike button1 five times(for instance , button1 is cliked everytime),the result that the button1's slot function is executed five times.how to exeute once button1's slot function ,the rest can't be executed. that's not over,when i go on executing the same Operation ,the result is the same that once solt function is executed ,the rest can't be executed.

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Have you tried disabling the buttons so that they can't be clicked? This way, you don't need to cancel signals. See my last post at http://qt-project.org/forums/viewthread/34029/P15/

      Anyway, you can use QCoreAppication::removePostedEvents() to remove QUEUED signals (Qt::QueuedConnection), but I don't think you can remove DIRECT signals (Qt::DirectConnection).

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • F Offline
        F Offline
        foxgod
        wrote on last edited by
        #3

        it's no affcet that the button is disabled ,for instance the frist five times, we can prevent the rest solt,but when i want to go on cliking the second five times ,how to do ?

        and QCoreAppication::removePostedEvents() is also no effect too.when i use Qt::QueuedConnection.

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          When you do want to prevent that the user can press the button multiple times until the first press isn't handled yet the disabling should do it.

          When you don't want that the same button is consecutively pressed multiple times you need to handle this in your application logic.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • F Offline
            F Offline
            foxgod
            wrote on last edited by
            #5

            hwo to do with in my application.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dbzhang800
              wrote on last edited by
              #6

              Hi, IMO, all the solutions given by JKSH and raven-worx should works.

              You had better given your code(a simple example that can reproduce your problem) if you find that doesn't work for you.

              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