0

I am about to start designing a UI. The UI is expected to be complex and will have several screens one of which will be a text editor. The application is in C++ and in order to leverage some existing functionality, I have decided to use Qt for the UI. However, I want to be able to write the UI in such a way that it is easy to replace Qt with any other UI library at a later point - or even use different libraries for different platforms.

I am leaning towards containing the QT objects in my own classes and using my classes throughout. Is this a good design? I preferred this as opposed to sub-classing(which is recommended by Qt) as subclassing seems to be a very rigid binding. However, this means that I will have to write a wrapper for every method that Qt exposes and I will also not be able to use QtCreator.

What do you think? Could you describe the advantages/disadvantages of the choice of method. It would be great if you could point me to any examples or to any good design principles.

go4sri
  • 1,490
  • 2
  • 15
  • 29
  • How do you imagine replacing UI library without rewriting UI? – Kamil Klimek Jun 29 '12 at 11:30
  • I wanted to have a set of high level APIs in my class that could internally map to the UI library specific calls.So, if I change the library, my class' APIs will remain the same, only the internal implementation would change... – go4sri Jun 29 '12 at 12:22
  • 1
    You realize that UI libraries are already some "high level api" for gui? So if I understood well, you want to spend undefined ammount of time to make "high level api" on another high level api for every ui you find. Wouldn't it be easier to just write another UI after library switch, instead of writing another "high level api" implementation every time you switch ui library? Take a look at transmission: http://www.transmissionbt.com/ they simply write another UIs – Kamil Klimek Jun 29 '12 at 13:09
  • Thank you. The example helped. This is along the lines of what I was looking for. – go4sri Jul 03 '12 at 14:47

1 Answers1

0

You don't. The GUI libraries are the abstraction. If you really want to compile your application with different backends - you might look into WxWidgets. But be warned - the library is very different from Qt.

elcuco
  • 8,948
  • 9
  • 47
  • 69