when having a closer look at libaries like Qt, I've noticed some of them works like this:
1 #include <QApplication>
2 #include <QTextEdit>
3
4 int main(int argv, char **args)
5 {
6 QApplication app(argv, args);
7
8 QTextEdit textEdit;
9 textEdit.show();
10
11 return app.exec();
12 }
So although there is no direct relation between app and textedit, app somehow knows that I created textEdit, as on calling app.exec() it will dispatch events to textEdit. How does that work? The only way I can think about is, having a static function registerWidget and a static vector<>-structure in QApplication, and in the Constructor of QTextEdit (or any widget) it calls QApplication::registerWidget(self). Is this ok to do so or is there any better way to do this? (not talking about gui-libaries but this self-storing/registering thing in general)