What is an event loop in Qt?

12,948

Now, when we say event loop, does it mean that there is some while loop running in the internal code of Qt, and in that while loop the method of handling signals and slots is written?

In a sense, yes. Most software these days sits and waits for events -- user input, network traffic, timer events, sensors, etc. -- and responds accordingly.

This is not specific to Qt. It's a common design pattern you'll find everywhere from Windows to Android to Arduino.

Share:
12,948

Related videos on Youtube

Aquarius_Girl
Author by

Aquarius_Girl

Arts and Crafts.stackexchange.com is in public beta now. Join us!

Updated on June 04, 2022

Comments

  • Aquarius_Girl
    Aquarius_Girl 7 months

    I have understood the following regarding QApplication's exec function:

    QApplication exec starts the main event loop. It launches the GUI. It processes the signals and calls appropriate slots on receiving them. It waits until exit is called and returns the value which was set in exit.

    Now, when we say event loop, does it mean that there is some while loop running in the internal code of Qt, and in that while loop the method of handling signals and slots is written?

    • Omid CompSCI
      Omid CompSCI about 6 years
      Event loop means that your code is continuously running, think about it as being refreshed every time, so changes will be seen and made continuously based off your cases you have.
    • thuga
      thuga about 6 years
      Directly connected slots don't go to the event queue, only queued connections.
    • Andre
      Andre about 6 years
      This was really helpful to me, have a look link
    • Kuba hasn't forgotten Monica
      Kuba hasn't forgotten Monica about 6 years
      Note that the event loop has nothing to do with the concept of signals and slots per se. It is used as an implementation detail in delivering slot/functor calls in queued connections or across threads in automatic connections.

Related