No, that's not the problem. I just want the program to "wait" until the variable is set. I dit it like you would do it in C. But it won't work in Qt.
The problem is your understanding. The remote server cannot magically change a variable in your program... your code, regardless of language, has to do that in response to receiving something from the server. Your while loop contains nothing that will change the variable, so it will spin at 100% CPU waiting for the variable to be changed by some other part of your code that is able to run 'simultaneously': this must be in another thread you tell us you do not have.

You have three ways to make this work:
  • If you use Qt networking asynchronously and in a single thread (as intended) then the program must be waiting at the Qt event loop in order to process the response from the server and change your variable. Your busy wait loop is not allowing that to happen so your variable cannot change that way.
  • If you have the networking in a second thread accessing a shared variable then you need to ensure accesses are consistent. The naïve approach might work some of the time but you generally must ensure that the variable is never accessed from both threads at the same time with a mutex.
  • If you have the networking in a second thread but are using signals and slots to ensure that the variable is only written from the main thread then you must ensure the program reaches the Qt event loop and processes queued signals.

All require you to think about how you have designed the program. The first option is the cleanest IMO.