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 clear pending signals in the queue?
Forum Update on Monday, May 27th 2025

How to clear pending signals in the queue?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 872 Views
  • 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.
  • D Offline
    D Offline
    Dmitriano
    wrote on last edited by Dmitriano
    #1

    Consider the following scenario: an object of class A is created in thread 1 and an object of class B is created in thread 2. Both A and B are QObjects. A connects to a signal emitted by B with QueuedConnection.

    Is there a way to stop thread 2, destroy object B and clear all the pending signals from B to prevent the handler in object A from being called after B is destroyed?

    There is QCoreApplication::removePostedEvents, but it is not clear how to use it.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      No but you can use the B::destroyed signal to tell A when B is no more and let A skip the connected slot

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      3

      • Login

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