I have a question about style... I am writing an application where my view is a View class derived from QGLWidget, and is initialized with the Model class and the parent widget, which in this case will be a QMainWindow, or a class derived from it. I used to have this in my main:
QMainWindow* mainWin = new QMainWindow();
Model model;
View view(model, mainWindow);
mainWin->setCentralWidget(&view);
Everything was working fine, but I decided that I need to subclass QMainWindow and make it an app specific MainWindow, as I suspect I should have done since the beginning... the problem now is where do I create and how do I hook up the model and the view to the MainWindow? I tried this:
MainWindow::MainWindow(){
Model* model = new Model();
View* view = new View(*model, this);
...
}
The problem is, I feel nervous about sending "this" to the View's constructor, even if it works now I feel this should lead to problems in the future... As I am new to QT, I would appreciate anyone telling me what is the correct way/style to accomplish this...
Thanks a lot!
Bookmarks