[Qt-interest] How do QApplication relates to QWidget

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Wed Jul 28 11:18:51 CEST 2010


wei wrote on Wednesday, July 28, 2010 9:27 AM:

> ...
> So how can "app" know it has a widget named "win"?

Actually it is the other way around: "win" (the QWidget based object) knows that there is an "app". In fact there exists a global instance thereof and you can also access it from your code with http://doc.qt.nokia.com/4.6/qapplication.html#qApp

And by "knowing" the "app" any QWidget (or any other class that needs access to "system resources") can register with and use those resources initialised previously by the QApplication instance (or for console only applications QCoreApplication).

Cheers, Oliver 
-- 
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22



More information about the Qt-interest-old mailing list