Slashdot Mirror


GTK-- vs. QT

spirality asks: "The company I work for is getting ready to decide on a GUI Toolkit for our Computational Modeling Toolkit (CoMeT, www.cometsolutions.com). We would like C++ compatibility and ports to various Unices and Win32 platforms. Not supprisingly we've come up with two choices, GTK-- and QT. I've attempted to compare the two by doing alot of web surfing and searching, but I've come up with things that are consistently one or more years old. So, the question I pose is what are the (dis)advatages of GTK-- and QT, and why would I choose one of these toolkits over the other? Overall functionality, momentum for future growth, ease of use, licensing, and pretty much anything else is relevant to our decision." With QT now at version 3.0 and GTK now in the 1.2.x revisions, maybe it's time to give the two libraries some fair comparison and discuss the new features, advantages, and disadvantages of each?

13 of 325 comments (clear)

  1. Qt if you need Win32 by Ami+Ganguli · · Score: 5, Informative

    I actually prefer GTK+ and I think it's a better bet long-term, but I don't think the cross-platform aspect of the library gets much developer attention.

    Being cross-platform is a major selling point for commerical Qt users, however, so if you need your apps to work on Windows then it's clearly the way to go.

    --
    It is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail. - Abraham Maslow
    1. Re:Qt if you need Win32 by hattig · · Score: 5, Informative
      Knowing companies like I do, they will go with the most expensive solution - because expense usually means support. In this case QT is clearly the way to go, as everyone is pointing out (okay, wxWindows is another good choice, but I have no experience with this system).

      QT has an easier to program API, is quick to program in, has great documentation, has support, has a huge wealth of existing code examples, and is supported on Windows. GTK is not supported on Windows, and is a one-man port job. Fine for free software like the gimp, but not for a commercial application. Don't save a couple of grand on the GUI toolkit and get yourself a lot more costs in support that you have to provide because of problems.

      GTK2 might solve a lot of the problems in the current GTK of course, but I am not qualified to comment about that. And do you really want to program using a just finalised API?

      QT just does things right. 'nuff said.

  2. wxWindows (slightly OT) by Balinares · · Score: 5, Informative

    You may also want to take a look at the wxWindows toolkit. It's a wrapper over what's available on a given platform (the native API in Win32, GTK in the Unix world, and there's a Mac port in progress, I believe). Good stuff, definitely, especially if what you want is C++ and portability. Note that your apps will look totally windowsy on win32, so your users will not be confused by their look.

    --

    -- B.
    This sig does in fact not have the property it claims not to have.
    1. Re:wxWindows (slightly OT) by Sludge · · Score: 5, Informative
      I second this, and find it not offtopic at all. wxWindows doesn't get anywhere near as much press as the other toolkits, but it's got fully fleshed out documentation available in a number of formats, active developers, four mailing lists of which I can attest the developer one getting 15-20 messages a day and ships with tons of code samples.

      The license it's under is acceptable (to me), and there are working large apps such as Audacity out there.

      When I discovered all of this, I decided to look into the technology side of things. To throw more goodness at you, let me say reiterate that the toolkit looks native to your environment which is a big win. On top of that, it lets you do things which aren't lowest common denominator and exist in only one or more environments, such as toolbar icons in Windows.

      I also like the class hierarchy. I had never done GUI programming before but everything came across rather clearly when I started reading the documentation.

      Additional to all the "low level" GUI junk, it also contains some routines for networks and a portable wxString class which is a lot like stl::string with more methods added. I found myself using this almost immediately and I haven't looked back.

      It's worth learning this stuff just to get away from MFC without taking the speed hit of learning Java/Swing and having to learn a whole new language and culture. There is even some boasting about how 'the Java honeymoon is over' on the page, stating that wxWindows is actually a more portable toolkit. :) ymmv.

      There are both Python and Perl bindings for it. I haven't looked into either really, but at least the Python ones seem to be of high quality as a number of people on the mailing list are Python programmers.

      Check it out before coming to a conclusion of what toolkit to use. It's worked for me.

    2. Re:wxWindows (slightly OT) by mill · · Score: 5, Informative
      If it hasn't been mentioned yet

      Al Stevens took a look at both Qt and Gtk-- in the September and October issues of Dr Dobbs Journal.

      What he didn't like with Qt:

      • No namespaces
      • Language extensions to implement slots
      • An ill-organized and unnecessary RTTI mechanism
      • Custom rather than standard containers
      • Questionable C++ coding conventions

      The last (I think. I only have October) refers to that Qt takes ownership of objects instantiated on the heap i.e. new without a corresponding delete. Which means you have to do all instantiating on the heap because there is no portable way for Qt to know if it is on the stack, external, or static memory.

      He thinks Gtk-- remedy all these problems and he actually found the tutorial funny albeit a work in progress.

      /mill

  3. licensing by Cardinal+Biggles · · Score: 5, Informative
    Overall functionality, momentum for future growth, ease of use, licensing, and pretty much anything else is relevant to our decision.

    To pick up your point on licensing, Qt is either GPL or pay. So if your application will also be GPL, it's free, if your application will not be GPL you will have to pay up for Qt. GTK is LGPL AFAIK (enough acronyms for you? ;-) so that will not stand in the way of making your app non-free.

    BTW, if you know C++ and want to get to know a bit about Qt, they have a pretty good tutorial online here. Just walking through the examples made me realize just how cool it is, and how much you can do in just a few lines of code.

  4. GTK+ C++ wrappers by HalfFlat · · Score: 5, Informative

    I worked on a rushed project earlier this year, and used the gtk-- C++ wrapper for GTK, as well as the gnome-- wrapper (then still very much under development) for the Gnome libraries, specifically the canvas.

    Personally, I found it frustrating to use. As these wrappers are still being worked on, the documentation is sketchy. The object-owning semantics are confusing (at least to me) - I was forever leaking memory or prematurely destroying objects. Trying to destroy something from within a menu callback I recall was particularly noisome. The gnome-- canvas wrappers were a moving target, though they may have since stabilised, and didn't fully expose the canvas API. Writing one's own canvas items is done in C, and then wrapped.

    Perhaps with more persistance I might have figured out how to set up keyboard acceleration, but it is at anyrate a real battle to find documentation that explains what is going on with it. AFAIK, there is no straightforward way of making a multiple file selection in GTK+ 1.2. In gnome canvas (not GTK+, but a close cousin) there is promised functionality that is simply not implemented - I'm thinking here of smoothed lines, for which the code reads:

    /* FIXME */

    I haven't used QT yet. It certainly looks pretty, and a quick glance at the example code and docs provided seems to indicate that it's not too complicated, and well documented. I'd certainly shy away from GTK+ if a C++ interface is required.

    The new version of GTK under development should address many of the shortcomings of the current toolkit, and includes goodies such as Pango. It is not yet in a stable state, however, with the API still undergoing final tweaking I believe.

  5. Mozilla (slightly OT too) by mvw · · Score: 5, Informative
    Another alternative is using Mozilla as IDE. This might sound a bit crazy right now, but I believe this idea will get more followers, if Mozilla gets more and more stable.

    An example is the Komodo IDE by ActiveState, which uses XUL.

    XUL is the next generation browser application platform. Simply speaking, the Mozilla team chose an approach very similiar to JAVA to come closer to a platform independent graphical user interface:

    • implement a set of base compenents on the most popular platforms (Win32, Mac, UNIX, ..), that render your JAVA specific widgets in terms of the native GUI.
    • implement your applications in your JAVA language
    • compile application
    • distribute JAVA binaries

    XUL goes one step farther, as there is no compilation step.

    The XUL application implementation language is a XML language that together with cascading style sheets and JavaScript glue will yield an application one starts in the browser by opening the .xul document.

    A possible advantage of XUL might become the relative ease of application development, change and distribution.

    Possible problems will be similiar to the ones known from JAVA. The qualitiy of XUL applications will stand and fall with the quality of the XUL implementation for a specific platform, which right now means the quality of its Mozilla or Netscape implementation.

    Of course, compared to JAVA, which has underwent several larger development cycles and now features mighty libraries, XUL is a bleeding edge technology at its beginnings.

    However it is still possible to make direct use of the various Mozilla widgets as well from C++.

  6. Re:What about gimp? by Ami+Ganguli · · Score: 5, Informative

    It exists, but I don't think it's maintained as well. The primary developers don't really care about Win32, so maintaining it is left to a few masochists :-).

    --
    It is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail. - Abraham Maslow
  7. New GTK+ by JanneM · · Score: 4, Informative

    Don't forget that an all-new GTK+ version is just coming out, a cleaner design, vastly improved i18n support, and all. I suggest you look at GTK2 (and it's C++ wrappers) as well, as this is what's going to be used, rather than the current version.

    /Janne

    --
    Trust the Computer. The Computer is your friend.
  8. Some points from using Qt. by hpj · · Score: 5, Informative

    I have been using Qt for some years now starting with Qt 1.0 some years ago. I have also tried to both patch GTK+ programs and in one instance port one of my Qt applications to GTK+ (I was preferring gnome at the time).

    The advantages I can see from using Qt is:

    * Superb design. The OO design of Qt is really thought out. There are virtual function to do all the basic things you can think of and if you think of something really clever there are lowlevel routines to do that too.

    * Superb documentation. A comprehensive, hypertext help and in Qt3 an included help browser. This is really an advantage since GTK+ not really being supported by a commercial entity suffer from lots of "I'll rather code than document" in the libraries.

    * Good migration path to new versions. I have a program consisting of ~100000 lines of code (An Oracle client http://www.globecom.net/tora) which I migrated to Qt3.0 in about 2 hours, some of that time was spent using Qt3 specific features also like docked windows where appropriate.

    * Not only a GUI toolkit. It also includes primitives for handling threading, I/O (files and sockets), UNICODE conversions and also some basic template classes made mostly obsolete now that STL is starting to actually work in GCC.

    * Truly multiple platform. The application above was ported to Windows in about a day, all of the problems related to the fact that Visual C++ understands a different dialect of C++ than most of us are used to and that took some time write around, none of it was Qt specific. The extra thread and I/O classes really helps here as well.

    /Mauritz
    GlobeCom AB

  9. My company went through this... by cjhuitt · · Score: 5, Informative
    About a year ago, the company I work for went through this. (This was before I worked for them.) The company debated the merits of Gtk-- and Qt. The basic conclusions were that Qt would (or at least, should) have the better support and documentation, and lack minor irregularities. However, when it was all computed, the deciding factor was the licensing fees. Since our software would be quasi-commercial (we are a consulting company, but for a fee, we provide companies with portions of our software as well) we would have to pay the licensing fee for Qt. This was a lot more than was thought our ~6 person (at the time) company could afford, so we went with Gtk-- pretty much only for that reason.

    Now that we have been using Gtk--, we have relatively few regrets. The documentation was poor, for a time, but they have semi-recently improved the documentation, and it is quite workable. There are some small things that you would think would be done differently, but overall they are very minor and easy to live with.

    Since we aren't concerned (yet) with porting our software, that wasn't much of an issue. Of course, your situation may be different there.

    Finally, echoing what other people have said here, Gtk-- can be quite low level at times. I would recommend that if you decide upon Gtk--, you do what our company has done. We created our own set of libraries that provide standard looks to things with minimal hassle, derived from the Gtk-- classes. An example of this would be windows. We have our own window class that sets up standard options that Gtk-- allows to vary considerably. (Additionally, it automatically checks for certain keystrokes, like the F1 key, and signals that fact.) Making a button class would be similar, so all of your buttons are approximately the same size, have the same shading, etc. We were late in figuring this out, but it has greatly simplified our code and made our program look much more consistent.

  10. More complete list of links: by Futurepower(tm) · · Score: 5, Informative


    GTK:
    GTK

    QT:
    QT
    Excellent QT Tutorial

    wxWindows:
    wxWindows
    wxPython

    Mozilla:
    Mozilla
    Cross-platform implementation of COM
    develop your UI's in an XML dialect called XUL

    Others:
    FLTK
    Fox Toolkit

    Side-by-side comparison of GUI Toolkits:
    The GUI Toolkit and Framework Page

    I needed this list for my own use. Maybe it will be of interest to you.

    --
    Bush's education improvements were