8

Put shortly: For those familiar with language bindings in Qt and Gtk+. E.g. python and ruby. Are there any quality or capability difference?

More background: I know C++ and Qt very well. Minimal experience with Gtk+. I know C++ is not ideal for language bindings due to the lack of a well defined ABI (application binary interface). I also read that Gtk+ was designed to be bound to other languages. So I wonder how this manifets itself in practice. Are the Gtk+ bindings better maintained or work better in some way than their Qt counterparts?

I am presently quite interested in the Go language, and they have started developing Gtk+ bindings. However C++ bindings is far away. It makes me wonder whether learning Gtk+ is worth it.

2
  • What about Vala [live.gnome.org/Vala]? its a great new language (much better than C++). Its like C# but produces native code and it is specially for GTK+ development.
    – lepe
    Dec 28, 2011 at 4:44
  • I have thought about it but my main interest was in Go. Having a way of coding GUIs was a second concern. Vala seems very C#/Java like. I would have prefered a fresher approach similar to Go built on top of GObject. May 13, 2013 at 15:59

5 Answers 5

10

I've used GTK and Qt in C++ and also PyGTK and PyQt in Python quite extensively.

Qt beats GTK hands down - its a much more flexible, modern and clean API. GTK is also lacking some features that are important to me. From a framework point of view, I'd recommend Qt.

As for langauge bindings (I can only speak about Python, since I've never used the Ruby equivalents), I think PyGTK (using Glade and a wrapper like Padraig Bradys libglade) make GUI programming insanely easy and fun. However, if you can GPL your software (or pay the license fee), then PyQt is also a good option, and while not quite as friendly as PyGTK + Glade (in that with GTK you can define your UI in Glade as a separate XML file, so you can tweak the UI without touching code; in Qt if you want to use QtDesigner, you have to generate code using uic, if I remember correctly) the API itself is really really nice to use and mirrors the Qt frameworks clean design very closely.

Over all, I'd probably recommend using PyQt over PyGTK, but I may be biased since I much prefer Qt over GTK nowadays, though you could try both out and see which you prefer - they are both almost trivial to get working.

If you are looking for a great book on PyQt, I'd recomment Rapid GUI Programming qith Python and Qt.

To summarize: IMHO Qt beats GTK in both quality and capability. Both PyGTK and PyQt are of excellent quality and capability mirrors the underlying framework, though PyGTK can load Glade xml files.

4
  • Thanks for the input :-) Actually Qt has allowed you to save your Qt designer files as XML and load them directly for some time now. I am reading up on Gtk+ Model-View-Controller stuff. GtkTreeView etc. So far I think the design looks better than Qt's solution. But I haven't actually used it so I might be wrong. Any comments on that? Are there particular areas in Qt you find easier to work with than Gtk? E.g. layout, signal slot system, creating new widgets or just simply the fact that C++ is easier to work with than C? May 12, 2010 at 8:18
  • Interesting, when I was looking for it a while ago, I didn't find anything.. I like Qts signal-slot mechanism, its very flexible and easy to use; I really like the graphicsview system for Qt better than the GTK equivelents and I found that the Qt widget set is more complete and feature rich (eg without clunky extensions, GTK has no support for dockable windows). I do most of my work in C++ now and I find it convenient and easy (not quite as easy as Python, but close enough that I'll happily write Qt code in C++, especially drawing code, without worrying about code complexity)
    – user21037
    May 12, 2010 at 16:37
  • Okay, interesting. I did not think of all the other APIs Qt has, like graphicsview. Which is indeed quite nice. I looked at GtkComboBox and GtkTreeView and that looked better designed than QComboBox and QTreeView. Easier to to put widgets into columns and define model. What do you mean by clunky extensions? The other GObject based APIs like Clutter etc? May 13, 2010 at 14:35
  • I cant find an example now, perhaps its improved since i looked, but I had some problems installing advanced extension widgets, especially on Windows, but even on linux. The ComboBoxes are indeed a little bit easier to use in GTK though. I've never needed to use them too much, so I don't know if Qts more complex ones are more powerful or not. I do like Qts other libraries a lot though: QtConcurrent, QtWebkit, Graphics View and QtNetwork especially. I guess some people would prefer not to have a framework bundle too much, but I like it in Qts case.
    – user21037
    May 13, 2010 at 15:32
2

I think that GTK bindings are older than Qt ones (and so a bit more mature) but they are both usable and your previous knowledge of Qt should be the main factor in your choice.

I developed small GUIs using both Qt and GTK with their python bindings and found the two equivalent. Some regrets though on the PyQt bindings with Qt container (QVector, ...) that are not translated into regular python data structure and thus add a bit of complexity to the code. I didn't recall the same issues using PyGTK.

1
  • QVariant, and other noise is not needed, if you use PyQt with python3
    – pihentagy
    Jun 2, 2010 at 15:19
1

I have worked with both PyQt and PyGTK and I would say they're both regularly mantained and synched with their parent frameworks. However, and this is completely subjective, I found more rewarding working with PyGTK than with PyQt, even if I hadn't previously written any code using GTK. If you know well Qt, go with Qt though.

1

I have been trying a few combinations around Qt : RubyQt, JRuby + Jambi, PyQt. The first one quickly ends up in various segmentation-faults. My Qt skills may be the problem but all in all the seg faults are not quite readable. The forum for RubyQt is nearly dead so don't expect to find much information there.

So I moved to JRuby + Jambi. This worked until well, I reached some missing functions here and there. Plus I had to implement a proper signal/connect for JRuby. So, more or less a hack. Not convincing.

Finally I moved to Python (wich I don't like very much). But woooh, what a difference. Bindings are up to date, I have still to ecnounter a segmetatio fault, error messages are most of the time very explanatory. So as far as I'm concerned Python+Qt is a clear winner.

Please note that I was trying these combinations in order to find a proper language/qt binding so that I can create a production ready with my commutation hours (roughly 2 hours a day). So my tolerance to small-but-annoying problems such as segmentation faults is 0. I also have to develop on Windows and Linux. So Windows installation is necessary (and once again, Python is a clear winner here).

0

there are C++ gtk+ bindings. Google for gtkmm.

1
  • I know. I am not asking if they exist. But about their quality May 11, 2010 at 15:38

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.