开发者

Simple Desktop GUI Architecture

Previously while designing desktop applications, I have always found it hard to architecture a clean way for different windows 开发者_如何学Cto communicate with each other.

For example: A settings/option dialog window that modifies the behavior of the main window.

Would making my "Main" (e.g. where there should only ever be one instance of a window visible at a time) Singletons be a good idea? Since there are only supposed to be one at a time anyways?

This would make it easier, and cleaner for separate windows to communicate.

If the above is true, then I could add Facade-like methods for a clean interface to other windows.

For example: MainWindow.setFont(Font f);

Thanks for any input.


A good read on the topic is GUI Architectures from Martin Fowler which covers various design patterns. For example the Observer Synchronization pattern might work for you in the context of the referenced article.

If you can, I suggest that you stick to some well known framework since writing your own can be a daunting task.


This is one of things that Qt gets right. If you want to communicate to a window send it a signal - then the window can deal with receiving the signal or not, the sender doesn't need to care if it even exists.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜