I have application which has
MainWindow that is divided in three main parts:
Thing is, all three parts need to communicate between themselves. For example, there is a
QListView in left section where you select items, and depending on the selected item options change in the right section.
I have come up with three solutions:
- draw everything within the
MainWindowwhich would make
MainWindowone big superclass:
This solution solves all problems with communication between widgets because all of them are part of
MainWindow::ui but then I get one big (potentially messy) class.
- put each section in it’s own class and make
This solution is… well a singleton. And I don’t really like singletons. I will have access to
MainWindow from everywhere (essentially I am creating a global variable) and I would still have to expose
::uis of other sections) via getter which would mean that everything will have access to
- put each section in it’s own class and connect everything via signals and slots:
This would probably be the best solution but with this solution I need to create getter for each widget from
EachSection::ui (to be able to connect it in
MainWindow with it’s counterparts), I would need a lot of calls to
connect() and I also have a problem if two slots react to same signal but they need to react in specific order.
So what would be the best approach?
Source: Windows Questions C++