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 can I interrupt, or pause, a loop so that a keystroke or pushbotton click is recognised?

How can I interrupt, or pause, a loop so that a keystroke or pushbotton click is recognised?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.3k 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.
  • R Offline
    R Offline
    russell
    wrote on last edited by
    #1

    In a graphical program, I can lauch a loop in which the contents of a window change as the loop evolves. I would like to be able to interrupt this, as the loop can potentially go on for ever. But everything seems to be on hold until the loop finishes, sometimes by typing Ctrl-C. QCoreApplication::flush does nothing, and neither does anything else I have tried. There is probably a simple answer to this question, but I haven't found it. Has anyone any ideas?

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

      Hi and welcome to devnet,

      Such loops should be moved in their own thread to avoid locking the GUI. Have a look at the mandelbrot example, it should give you a good starting point.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qxoz
        wrote on last edited by
        #3

        Hi russell.
        Take a look to "this article":http://doc.qt.digia.com/qq/qq27-responsive-guis.html .

        1 Reply Last reply
        0
        • R Offline
          R Offline
          russell
          wrote on last edited by
          #4

          Thank you both, qxoz and SGaist. With the help of the links you gave me, I finally managed to figure out how to do what I wanted.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            You're welcome !

            And since you have it working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            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