QApplication is a singleton, so it would be pretty easy: QWidget to do: QApplication.instance() and interact with the QApplication instance.
In fact, trying to instantiate QWidget before QApplication produces an error:
>>> QtGui.QWidget() QWidget: Must construct a QApplication before a QPaintDevice
Most likely this is what happens.
Edit: I downloaded qt sources and, in fact, in line src/gui/kernel/qwidget.cpp , line 328, there is:
if (!qApp) { qFatal("QWidget: Must construct a QApplication before a QPaintDevice"); return; }
Where qApp is a pointer to a QApplication instance (i.e., it is equivalent to calling QApplication.instance() ).
So at the end, QWidget interacts with QApplication with a global variable, although this is not necessary. They probably use qApp instead of QApplication.instance() to avoid unnecessary overhead that can occur when creating / destroying many QWidget s.
Bakuriu
source share