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. Controlling infinite loop with button click - Qt
Forum Updated to NodeBB v4.3 + New Features

Controlling infinite loop with button click - Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 869 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.
  • ankurt44A Offline
    ankurt44A Offline
    ankurt44
    wrote on last edited by
    #1

    Consider I have two buttons "start" and "end", and a slot "start_game()". The method "start_game()" looks like:

    void start_game()
    {
           //an infinite loop that refreshes(re-paints) a widget
           while(/*some flag maybe*/)
           {
                     //update paint widget
                     //exit when "end" button is clicked
           }
    }
    

    I can easily connect "clicked(bool)" signal of the "start" button with above method containing infinite loop. I could not understand how can I control this loop, for example I want to exit this loop on "end" button's click. I understand that the loop blocks the main event loop. What is the efficient wat of getting such functionality.

    Best regards

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

      Hi and welcome to devnet,

      Since your comment is update paint widget, why do you need such a loop ?

      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