gtkmm (previously known as Gtk–) is the official C++ interface for the popular GUI library GTK+. Highlights include typesafe callbacks, widgets extensible via inheritance and a comprehensive set of widget classes that can be freely combined to quickly create complex user interfaces.
now we have a good looking C++ tool kit 🙂
I highly recommend it over KDE/QT. The api
works really really well, it’s a pleasure to work with
when you learn it, and the best of all, it’s Gtk!
GTK+ is the most popular toolkit, the one with
the most bindings (even C, which QT lacks support for),
and one with the most apps developed for.
GTKmm also works with glade (interface builder, like QT designer), which now has extensions for it (glade–).
Why do you recommend it over KDE/QT ? KDE/QT are full C++ written not like the halfhearted wannabe OOP stuff made by GNOME zealots. I like to know why you prefer hacked stuff over well developed C++
Gtkmm is a true wrapper, you dont even touch the “GTK+” part
on it. It’s all C++ from begining to end, full compatible
with STL (more than QT actually), it has a signal system
that doesnt need a preprocessor and lets you bind metadata,
it doesnt force you to QString (use std::string if you want,
or a gstring wrapper for unicode and other stuff).
And the GTK guys are much smarter than the QT/KDE ones,
they realize that most developers do C (specially in unix
where all apis are in C) and not C++, so
they make their widgetset in a way it can be wrapped
by C++ or something else.
There used to be QT C bindings, but i think they are unmaintained now.
It might be that many people are using C for unix programming, but i think it was a good choice to build both QT and KDE around C++. Why? Because IMO it makes the core kde and qt code much easier to design, maintain, and use. And this is not really because it is C++, but because it is OOP in general.
I have never tried gtk–, but i have tried gtk+, but it was a long time ago. (im not even sure gnome was at 1.0 yet) The main reason im using KDE is because of its APIs as im hoping to contribute to it.
As for QT needing a preprocessor, so what? You need a preprocessor to turn your .c files into something the c compiler can understand too right? Only difference is that that one is built into the compiler, where qts is run by the makefile before the code is passed to g++. Sure it is an extra step, but that step makes a lot of things very easy.
For me, QT is a nice and modern toolkit that is even easy to use. It is entirely possible that gtkmm is that too, but that doesn’t mean that it is better than Qt.
I still believe the question remains unanswered, why is gtkmm better than qt?
that would be cool just for the hell of it.
I’d like to give gtkmm a try… but… it looks a little complicated. I mean: which versions of gtk+ libs do I need to work with gtkmm2? And, if I’ve already got older versions of gtk+ and gtkmm installed, which pieces need replacing? Do I need gnomemm? libsigc++? Bakery? GtkExtra–?
It would seem that getting all this stuff installed and working correctly would be very difficult for a novice like me, especially if I wanted to build it from source and install it by hand (which I would, so I could refer to the source as necessary). The docs don’t seem to be too much help here:
http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch02s02.html
And then, when I write something for a friend to try out, they have to go through the same hassle getting all the correct versions of libs installed.
Trying to remove older versions of gtk/gtkmm (to be replaced by the new one’s I’d download) using a graphical rpm tells me that I’ve got to uninstall every gtk-related app on my system in the process. Using Mandrake’s “Software Manager” gui rpm program, and searching for “gtk” shows *many* installed packages. This looks like a large complicated beast to me. [shrug] Just looking in /usr/lib yields
[john@localhost temp]$ cd /usr/lib
[john@localhost lib]$ ls *gtk*
libgconf-gtk-1.so.1@ libgtkgl.so.5.0.0*
libgconf-gtk-1.so.1.0.0* libgtkhtml.so.20@
libgnorbagtk.so.0@ libgtkhtml.so.20.1.0*
libgnorbagtk.so.0.0.0* libgtkmdk-0.1.so.6@
libgtk-1.2.so.0@ libgtkmdk-0.1.so.6.0.0*
libgtk-1.2.so.0.9.1* libgtksuperwin.so*
libgtkembedmoz.so* libgtkxmhtml.so.1@
libgtkgl.so.4@ libgtkxmhtml.so.1.0.1*
libgtkgl.so.5@ libgtkxtbin.so*
I don’t know where this is true, but what it is true that all GTK+ and related APIs/toolkits have terrible documentation. It took me two days to learn how to use Qt with Python (more specifically, 4 hours). And I tried to do so with GTK+, but the documentation doesn’t really help.
Besides, you mentioned how UNIX developers mostly use C. So? Most Unix hackers don’t know shit about desktop and desktop apps. 🙂
KDE is targeting the novice. Windows/Mac OS users. Qt can help with that. Most major programs are written in C++. Plus, in the long term, development cost would be much lower, because you can spend less on making multiple versions of a product for the 3 major desktop OS.
So because for now at least half of the Linux apps are in GTK+, this is only so because there aren’t much commercial developers targeting Linux. Once that happens, I expect Qt to rise in popularity. For example, KDE/Qt have very good IDEs – KDevelop (tried Gideon?), Klyix and Qt Designer. GTK? As a mention above, documentation is terrible for GTK+. So without a IDE, and without good documentation – I rather spend $2000 getting Qt.
>As for QT needing a preprocessor, so what? You need a >preprocessor to turn your .c files into something the c >compiler can understand too right?
It means you need all QT tools and environment to compile,
for someone that uses specific build systems, cross
compiling, etc I found gtk– much easier to work with.
Also, sigc++ is a wonderful thing, works without any
preprocessor and you can use it in your programs very very
easily.
> I’d like to give gtkmm a try… but… it looks a little
> complicated. I mean: which versions of gtk+ libs do I need
>to work with gtkmm2?
the same major version as GTK.
for gtk 1.2.x, gtkmm 1.2.x , for gtk 2.x goes gtkmm 2.x.
Installing is easy, just get the gtkmm 2.x and sigc++ 1.4
packages/tarballs, compile and use. in the gtkmm package
comes the wrappers for atk/pango/etc all together.
GTK+ has the advantage of being LGPL, so anyone can create GPL or proprietary applications with it. This means you don’t have to spend money for a commercial version of QT. On the other hand, you probably get support from Trolltech if you do, and maybe some nicer commercial tools(don’t know here). While I have no grudge against trolltech and I do want them to keep succeeding as a buisness, if there was no Gnome, no GTK, then Trolltech would control all commecial application developement on linux(maybe not all, but all modern).
Just looking at this makes me think that if linux were to rule the desktop, the only commecial apps would be niche, and very high end, like Maya, CAD stuff, maybe Mathematica or Maple.
Anjuta[http://anjuta.sf.net] is a fantastic IDE (I think possibly the best I’ve ever used). So much better than KDevelop (although we’ll see when kdevelop 3.0 comes out).
As far as documentation is concerned, and learning the API, I found QT MUCH harder to learn, especially with that .moc crap (in fact I gave up because of that).
At any rate, I dont know why this article has turned into yet another KDE vs Gnome or QT vs GTK. Both have their strengths.
“It’s all C++ from begining to end, full compatible
with STL (more than QT actually)”
Yes, and that is bad. STL strings for example lack Unicode support. Qt could not use them at all. There are other cases like this which show that not using STL was the right thing to do for Qt.
GTKmm is only good if you want to write C++ AND use GTK+.
“As for QT needing a preprocessor, so what? You need a preprocessor to turn your .c files into something the c compiler can understand too right”
Psst. Don’t talk about that. Some zealots won’t use C anymore because of “crappy preprocessors” 😉
The GNOME people have actually found the need for a preprocessor too in order to increase their productivity. Take a look at GOB — now you can write Glib classes much faster. If poeple have an aversion to preprocessors they can always do the work of the preprocessor by hand (i.e. use a environment without one).
“if there was no Gnome, no GTK, then Trolltech would control all commecial application developement on linux(maybe not all, but all modern).”
Wrong (from my POV, I too have no crystal ball). There was the Harmony project. That was one of the big reasons Troll Tech licenced Qt under GPL. But regarding control: GNOME development today is evidently under the control of companies like SUN, Ximian, and Red Hat. At least they have a very big influence.
“Both have their strengths.”
True. GTK+ is the best C toolkit around, Qt the best C++ toolkit, and GTKmm is a C++ binding for GTK+ which eases the use of GTK+ from C++.
“As far as documentation is concerned, and learning the API, I found QT MUCH harder to learn, especially with that .moc crap (in fact I gave up because of that).”
Qt has the best documentation of any toolkit. There are still quite a couple of undocumented GTK+ methods. Why moc is a burden for you I can’t understand. Moc files are handled automatically by your automake stuff (just like GOB files under GNOME). You don’t touch them at all. It’s even described in the excellent Qt tutorial.
Regarding OO, you don’t want to use GObjects at all (unless you must). They are very costly. I guess that is the reason why they are only spacely used in GTK+ apps and why most GTK+ apps are programmed in a rather proceducal way and not OO at all.
Anjuta is nice, it beats KDevelop 2.x hands down. I never liked KDevelop 2.x. Gideon is different though. WAY different. And way nicer too.
On the documentation, I don’t know about C++, but I never manage to learn Python wrappers with GTK+. I mean, i learn from a tutorial, but after that, when I want to move on: blockage.
Never tried programming in C++ in any API :-D.
I gave gtkmm about a month, and it’s just not worth it. It is fairly painful to use compared to QT, and if you ever have a need to dive into the C internals – it’s an ugly wild goose chase. I’ve also yet to see a substantial project written with it.
If you look at their page where they list software that uses it – many of them are unmaintained, or experimental/toy projects. Nothing wrong with that, but I’m not into wasting a lot of time being a pioneer right now.
As an experiment I ported a couple of programs I had written on windows to it, and it took me about 2-3 weeks. When I tried to move them to QT it took me less than a week, quite a difference. My impression is that many of the high level interfaces are well thought out, but they sit on a complicated maze of fugly foundations.
So I honestly can’t believe anyone would recommend it from a developers point of view. Infact, it leads me to suspect whoever would do such a thing is either 1) Involved with it personally, having a vested interest in it or 2) Some GNOME/Debian whacko like the ones who recommended it to me in the first place.
KDE is targeting the novice.
This is only part of truth. KDE targets everyone. The day KDE only targets novices is the day i no longer use it. While the usability team is attempting to make KDE easier, they are not removing options.
It means you need all QT tools and environment to compile,
for someone that uses specific build systems, cross
compiling, etc I found gtk– much easier to work with.
I still don’t see the problem. Its a simple preprocessor, like the one built into C, only difference is that it is a small command line utility that comes with the libraries anyway, unless the packager has chosen to seperate things, in which case it comes with the devel packages.
I still haven’t seen any real reasons as to why gtkmm should be better than Qt.
While i haven’t actually personally tried gtkmm, the complaint that gtkmm is hard and annoying to use is one i have heard before. Can anyone actually explain why this is so?
> and if you ever have a need to dive into the C
> internals – it’s an ugly wild goose chase.
I understand that gtkmm is on top of gtk+ which is on top of X, so I see what you mean.
> My impression is that many of the high level interfaces
> are well thought out, but they sit on a complicated maze
> of fugly foundations.
Could gtkmm be rewritten to cut gtk+ out of the loop and go straight to X calls?
Rewriting gtkmm to bypass GTK+ defeats the whole purpose of using GTK+. It would because just another toolkit. Thanks to the niceness of current C++ compilers, most of the overhead of wrapping GTK+ with C++ is optimized out by compilers anyway.
As for the comment that KDE is targeting novice users, that’s hardly true. KDE, right now, is a great deal more customizable than GNOME 2.0 (and you don’t have to dig into the registry to do it) and is moving towards becoming still more powerful and customizable, while GNOME is moving towards becoming more streamlined and simple.
Quite funny actually. Once upon a time, the only feature GNOME could claim was how much the UI can be changed dramatically. And KDE was that it has little UI customization options. Now, ironically, the two opposing camps change sides. Hmmmm…
having learned both, i can reveal that Qt has a much shallower learning curve, allowing you to build and prototype applications within a few days of starting learning. Gtk– is much harder and IMHO only has similar functionality.
Gtk wins, of course, on portability as Qt isnt free under windows/macos.
these days i make a decision: is it a quick, small porject that doesnt have to be portable? if so then use Qt, but if portability is necessary then (ironically) i use Gtk.
> I’d like to give gtkmm a try… but… it looks a little
> complicated. I mean: which versions of gtk+ libs do I need
> to work with gtkmm2?
GTK+ 2. That is the whole point of gtkmm2 after all. I think we’ve made that clear in the announcement:
http://groups.google.de/groups?q=gtkmm+2.0.0&hl=en&lr=&ie=UTF-8&oe=…
> And, if I’ve already got older versions of gtk+ and gtkmm installed, which pieces need replacing?
gtkmm2 co-exists with gtkmm 1.2, just as gtk+ 2 co-exists with gtk+ 1.2.
> Do I need gnomemm? libsigc++? Bakery? GtkExtra–?
[snip]
> The docs don’t seem to be too much help here:
> http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch02s02.html
On the previous page, the dependencies are clearly listed:
http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch02.html#id2768244
I can’t imagine what made you think that you need extra stuff such as gnomemm, Bakery, or GtkExtra–.
> Trying to remove older versions of gtk/gtkmm (to be
> replaced by the new one’s I’d download) using a graphical
> rpm tells me that I’ve got to uninstall every gtk-related
> app on my system in the process.
That’s why new major versions of libraries co-exist with their old versions so you don’t need to remove old versions. You invented this problem yourself.
>> “It’s all C++ from begining to end, full compatible
>> with STL (more than QT actually)”
> Yes, and that is bad. STL strings for example lack Unicode >
> support. Qt could not use them at all. There are other cases
> like this which show that not using STL was the right thing
> to do for Qt.
That’s why gtkmm2 has Glib::ustring. But unlike QString it tries to be as similar to, and as compatible with, std::string:
http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch03s04.html