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. Post events before exec causes lost connects
Forum Updated to NodeBB v4.3 + New Features

Post events before exec causes lost connects

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 285 Views 2 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.
  • ocgltdO Offline
    ocgltdO Offline
    ocgltd
    wrote on last edited by
    #1

    I have created a simple, single thread, app in Qt6. My sole class creates a couple of timers and prints a qDebug message in the timeout slot. These messages never print.

    My class is created before the app.exec() in main, so before the event loop is executed. I suspect this is related. If I create QTimers, and connect the timeout signal before the event loop exec is called, are my signals-slots lost once exec is called? If so, what's the right way to handle this?

    Note: This question is about use of QTimer & Eventloop. Not looking for help with specific code. (i.e. theory)

    JonBJ 1 Reply Last reply
    0
    • ocgltdO ocgltd

      I have created a simple, single thread, app in Qt6. My sole class creates a couple of timers and prints a qDebug message in the timeout slot. These messages never print.

      My class is created before the app.exec() in main, so before the event loop is executed. I suspect this is related. If I create QTimers, and connect the timeout signal before the event loop exec is called, are my signals-slots lost once exec is called? If so, what's the right way to handle this?

      Note: This question is about use of QTimer & Eventloop. Not looking for help with specific code. (i.e. theory)

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @ocgltd said in Post events before exec causes lost connects:

      If I create QTimers, and connect the timeout signal before the event loop exec is called, are my signals-slots lost once exec is called?

      No. You are supposed to set up with connect()s before the event loop is called with exec(), that's fine. If an event arrived before the loop is entered that might be a different situation, but that is not what you say.

      If your situation is as simple as you say you should produce a standalone example.

      Axel SpoerlA 1 Reply Last reply
      1
      • JonBJ JonB

        @ocgltd said in Post events before exec causes lost connects:

        If I create QTimers, and connect the timeout signal before the event loop exec is called, are my signals-slots lost once exec is called?

        No. You are supposed to set up with connect()s before the event loop is called with exec(), that's fine. If an event arrived before the loop is entered that might be a different situation, but that is not what you say.

        If your situation is as simple as you say you should produce a standalone example.

        Axel SpoerlA Offline
        Axel SpoerlA Offline
        Axel Spoerl
        Moderators
        wrote on last edited by
        #3

        As @JonB said, the debug messages must be printed, if coded correctly.
        Please post your code.

        Software Engineer
        The Qt Company, Oslo

        1 Reply Last reply
        0
        • ocgltdO ocgltd has marked this topic as solved on
        • ocgltdO Offline
          ocgltdO Offline
          ocgltd
          wrote on last edited by
          #4

          After some testing I can confirm events (signals) are queued up and once .exec() is called those events are processed. Calling connect before .exec() always works fine.

          I think I was thrown by some old/wrong posts that posting events/connects before the event loop starts are lost.

          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