tags:

views:

381

answers:

2

Hello I'm working on a QT project based mainly on C libraries.

I like the way QT works, and would like to make a C++ wrapper(with similar QT style) for each C library I'm working with.

What are your recommendations and advices. What should I do, and what I shouldn't.

I would like to hear answers based on real life experience.

Thanks

A: 

Is there a reason not to just call the c libraries from c++?

I ask because this is the most major divergence of QT and GTK, QT is C++ native GTK is C native. A lot of developers state they don't like GTK mostly down to the way everything has to be handled in C.

ewanm89
There's a number of possible reasons, one of which being able to basically hide a lot of the boiler-plate code in the constructors/destructors for the class, also enabling you to just use RTTI instead of manually doing it each time. Creating the wrapper also means that in the main body of code, it can basically all be a single coding style.The benefits really depend on the developer, the situation, and the C code (some C code is simply a pain to work with to begin with, being able to hide is somewhere out of the way is often a nice ability- other code being much nicer to work with).
Kitsune
I was tired and think I missread, if it's c++ wrapper around c libraries, that is probably a rather good idea.
ewanm89
+2  A: 

There is a classic article on designing Qt-style APIs which might be helpful to you.

In general I'd recommend following the Qt style as much as possible, and hiding the details of the underlying library where you can. You can use the Qt source code as a reference - after all, Qt is a wrapper of C libraries to a large degree, making use of standard C, POSIX and platform-specific libraries.

Intransigent Parsnip