What's the difference between GTK and QT?

18,141

Solution 1

I'll try to answer your questions, without going in crazy directions.

  1. They are significantly different, even though they are both widget libs. Regular GTK+ is based on C, and QT on C++. Although bindings exist for almost every programming languages.

  2. You are fairly correct about GTK2, although there are so many GTK2 applications. I expect GTK2 to be in use for a while, just as GTK1 was. When push comes to shove, GTK2 is deprecated, and if you are starting fresh go GTK3.

  3. Remeber GTK, and QT, are just widget toolkits. For example... Gnome applications, use GTK and also the Gnome-Libs. If you want that, take a look at vala. It is considered simple, the vala compiles source-to-source directly to C, and has full bindings for many programming languages. You might also want to look at Anjuta, just make sure you have the new gtk3 versions. Apparently strait PyGTK only supports GTK2, current last I checked. If you are looking to avoid all Linux DE libs, I would suggest looking at QT. Plain QT is different from KDE applications, which include KDE libs. QT is considered very cross-platform, which is cool if you want to compile for non *nix. If you want to get started with QT + Python, look at PySide (LGPL) or PyQT (GPL). QT has some good GUI builders like qt creator, and qt-designer.

Solution 2

GTK and Qt are open-source cross-platform User Interface toolkits and development frameworks. These are the two most popular frameworks in use for Linux because they are open-source and give developers a powerful toolkit to design Graphical User Interfaces. GTK is used as the standard toolkit for the GNOME, LXDE and Xfce Desktop Environments while Qt is used for KDE.

If you code in C, then obviously go for GTK+

If you code in C++, go for Qt, otherwise you will ned Gtkmm (a C++ wrapper over GTK+)

If you code in Python, both GTK+ and Qt have bindings for the language: see PyGtk, PyQt and PySide (the one launched by Nokia themselves).

Share:
18,141

Related videos on Youtube

Nootrino
Author by

Nootrino

Updated on September 18, 2022

Comments

  • Nootrino
    Nootrino over 1 year

    Please bear with me as I'm a newcomer to Linux. I've been writing GUI programs in REALbasic on a Mac for several years. I'm trying to learn Python and I want to write GUI apps for Linux (primarily Ubuntu and Mint since they are the distros I have access to and they seem to be the most popular). I basically have three questions:

    1. Are there any significant differences between GTK and QT
    2. I've toyed with quickly and Glade on Ubuntu but I understand that they are based on GTK 2 and this is now obsolete. Is that correct?
    3. Are there any all-in-one editors that let me design a GUI and then add Python code to it? (for instance, add a button to a window in the editor, double click the button and then add the Python code that is to execute when the button is pressed)

    Sorry if these are really dumb questions but I want to start learning the 'right' tools from the start.

    • Admin
      Admin over 12 years
      I don't have time right now to answer your questions, but I can clarify something. Glade used to be both a library, a format for a UI definition file and an application to create those .glade files. Now we use GtkBuilder for what the Glade format used to do, and that is built in to GTK. Glade the application lives on as a great tool to make .ui files for GtkBuilder (or simply to test different layouts), and Glade 3.x certainly does do Gtk3 — though not everything is there at this moment.
    • Admin
      Admin over 12 years
      That is very helpful. So if I decide to use GTK as my toolkit then I'd use Glade to design the layout and another tool to link my Pyhton code and the UI design - correct?
    • Admin
      Admin over 12 years
      Yep, and that tool is part of GTK, so it's documented over here: developer.gnome.org/gtk3/3.1/GtkBuilder.html I'm linking you to the C documentation because it's pretty detailed, and when you're using PyGObject the only real difference will be the syntax. In Python, the names and stuff will look something like this: valadoc.org/gtk+-3.0/Gtk.Builder.html
  • Uri Herrera
    Uri Herrera over 12 years
    QT is a cross platform toolkit it is not only used in KDE, and so is GTK. AND please refrain from writting "txt lik dis"...
  • Dylan McCall
    Dylan McCall over 12 years
    If you're using Python, PyGTK is deprecated. For new projects you will be much better off using PyGObject (python-gobject in Ubuntu's repository): live.gnome.org/PyGObject PyGObject lets you connect to any library built on GLib (such as GTK) through Python, without any extra layers. You get something very much like PyGTK, but it goes about it quite differently. And, of course, PyGObject is the only way to talk to GTK3 through Python.
  • Nootrino
    Nootrino over 12 years
    Thanks for this. Anjuta pretty much looks like what I have been after. I'm going to play around with it a bit. If it's not right then I will look at QT. It strikes me that both GTK and QT achieve the same end result - it's just a matter of preference I guess.
  • Brad Henderson
    Brad Henderson over 12 years
    Qt is much more than just a widget toolkit. It is an entire framework, replicating large chunks of the STL and Boost.
  • J. M. Becker
    J. M. Becker over 12 years
    @scottl, I was not trying to limit QT. While QT is more capable than just widgets, it's in that context it became part of the potential solution.
  • J. M. Becker
    J. M. Becker over 12 years
    @Nootrino: you have to remember in the FLOSS world, there is often more than one established solution. The reason many people have chosen, one or the other, is based on their C vs, C++ standing. Of course, licence played a bigger part in the past. Regardless other frameworks in many languages exist, you usually agree more with one method.
  • J. M. Becker
    J. M. Becker over 12 years
    @Nootrino: I'm glad I was able to actually help!