Verify " globally accesible " qApp
-
Using an option to restart the discussion instead to continue the stale one - just Before somebody will complain about the dupe.
The older post somehow skipped HOW "qApp" became ONE and ONLY ONLY ONE GLOBAL value.
BTW -it also misrepresented QApplication and QCoreApplication - with or without "event loop". Not related to "qApp" pointer.
Re: [SOLVED] Which method of the main Widget returns the QApplication instance?
-
@AnneRanch said in Verify " globally accesible " qApp:
The older post somehow skipped HOW "qApp" became ONE and ONLY ONLY ONE GLOBAL value.
It became the one and only one global value by means of you creating it - the one and only one
QCoreApplication
instance you create inmain()
. There's no magic, the object sets a global pointer inside its constructor and gives that value back to you when requested throughQCoreApplication::instance()
.qApp
is just a convenience macro that callsQCoreApplication::instance
.PS. The relevant code: https://code.woboq.org/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp.html#_ZN23QCoreApplicationPrivate4initEv