I am implementing an application that is like Facebook in Qt5. For now in my App I just want to view profiles of people, add new ones and view detailed info of a profile. I decided on a MVC archetecture for my app. I want to know how the views/controllers can interact with the model classes
This is what I have so far: I have a few view/controller classes (as QT seems to mash both into one) which are:
- SingleProfileView (QWidget) <- show 1 profile
- MainView (QWidget)<- Main view which has navigation options ..etc
- ProfileListView (QWidget)<- Which shows the list of all profiles in my app at the moment
Each view is implemented using stacked widgets
- ProfileView (QWidget) has a stacked widget inside containing widgets ProfileListView and SingleProfileView
- Mainview (QWidget) has a stacked widget that contains ProfileView
These are my data classes
- ProfileModel <- data of 1 profile
- ProfileListModel <- List of all profiles (contains many profiles)
- AppModel <- Contains the ProfileList
The AppModel loads up data from a SQL DB and DB functions are abstracted.
One last class which is the "main class"
- MyApp <- class that has all the views and data (I would think of this as the controller)
How can I pass data between the AppModel and the views?
I was thinking of having the model class be a singleton class and all the views that need the model class just get the instance of it?
What I am talking about can be found here: https://doc.qt.io/archives/qq/qq10-mvc.html
My concern is this coupling the model and view/controller classes too much? This seems like playing with a global variable.