Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Passing control from Main loop
Xaegis last edited by
Hello. I have a very beginner question to ask.
It is my understanding that the main loop has the control for the UI elements. How do I pass control to my program logic in a way that avoids GIL? I am programming in C++ and an utter beginner and cannot figure out how this works. What does it look like?
Thank you in advance !
Hi and welcome
GIL ? , like in global interpreter lock ?
The QApplication::exec() is a event loop that runs the application.
Im not sure what you mean by
"How do I pass control to my program logic"
Except you if you just mean run your application.
In that case, you write your classes and functions.
Say when you click a button. a click event is generated.
If you connect a function to that event, your code is then run.
(Right click the button and select go to slot)
If you make a loop that runs forever, you will block the event loop and in that case the
application will hang.
To avoid that one could call QCoreApplication::processEvents() to avoid it hanging but in most cases such
heavy calculations should be done in a new Thread.
Hope it sort of answer what you ask.