Good day.

I have created a GUI that uses its buttons to change different states of a system. I want to be able to run a unending loop that reads data over the PCI bus inside of each event of a button. I have the buttons and I have the functions that run the unending loop that reads the PCI bus.
However, when the loop is running inside the event of the button I loose functionality of the gui.

So I basicly want to learn how to run a unending loop in the event of a button and still be able to control the GUI

I will try to explain with code:

Qt Code:
  1. void Controller::standby()
  2. {
  3. powerDownButton->setEnabled(true);
  4. standbyButton->setEnabled(false);
  5.  
  6. int val = 1;
  7. while (val == 1)
  8. {
  9. read_data();
  10.  
  11. //here I nead something to exit the loop when a button is pressed;
  12. //something that I can use to change val to another value and exit the loop
  13. }
To copy to clipboard, switch view to plain text mode 

Hope this post makes sense.
Thanks to anyone that can help!