I want to develop an application which has a graphical user interface that could be developed by using different widget toolkits. For example I want to use Qt, GTK+ or even ncurses as a building block for my user interface for the same application. Moreover users could choose which GUI implementation will be used during the next startup of the application without recompiling it first. I wonder what are possible design strategies and design patterns used in the implementation of this design?
The classic design pattern for multiple GUIs is MVC.
You have one model (application data and rules), the controllers (one per view) - these control UI interactions and mediate between the UI (views) and the model.
You can have different views talk to the controllers - one view can be Qt, another GTK+ or even a console application.
Why would you want that?
Each toolkit has its own strong points and weaknesses. If you want to design something that will work with them all, you will be limited by the cumulative sum of all of the weaknesses and gain none of the strong points.
For instance if you're using Qt then you won't be able to use QT's signals and slots. that will make writing the GUI and the interaction with it quite painful. You'll basically need to write a whole wrapper layer around something that is already a wrapper layer (to the native APIs)
I see no possible reason why a user would care to choose between Qt or GTK+ or ncourses. just select one thing and stick with it.
A commercial solution you might find interesting, that does decouple the user interface from the system logic and is both OS and render technology agnostic is Crank Software's Storyboard Suite.
One of the principle differences with this UI designer and runtime is that you build the user interface out of images/graphics and not widgets. This makes it easier to move your UI model between rendering technologies (ie fbdev, directFB, X11, SDL/QT/GTK). You tie the user interface elements to the system logic with Lua scripts, or custom C plugins if you need something very specific.
Of course a curses implementation might be a bit of a stretch, but there is always ascii art!
Thomas