In Qt main function, how does QApplication learn about Mainwindow?

Viewed 662

Looking at a simplest Qt Widget sample application that you can find from almost every Qt tutorial:

#include "notepad.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Notepad w;
    w.show();

    return a.exec();
}

There is one thing puzzles me. There are two major variables a and w here. a.exec() starts Qt's main loop, which suppose to interact with the main GUI component w. However, both of them live on stack and I don't see any code pass w somehow to a. So how does a be aware of the existence of w? Does the constructor of w initializes a static data structure that a can access to check the top-level widgets?

1 Answers
Related