QT and GTK on Linux, for development...

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
tetsujin
Posts: 426
Joined: Thu Nov 15, 2007 8:34 pm UTC
Location: Massachusetts
Contact:

QT and GTK on Linux, for development...

Postby tetsujin » Wed Jan 14, 2009 8:27 pm UTC

OK, so here's the thing - I've used Linux since 1996 or so but I never got around to learning to write GUI code (apart from a little bit of Tk and Lesstif in college...) Now I finally am feeling like it is really time to make this happen. Right now, though, I'm feeling a bit conflicted in choosing between GTK or QT for development. I generally use KDE, and that was always a pretty strong argument for QT... Though I wasn't always happy with the licensing options for QT (basically, GPL with exceptions, or a commercial license) - so I had been strongly considering GTK - though now QT 4.5 is going to be LGPL so maybe that's not such an issue any more... But I guess despite being mostly a KDE user I feel a bit more affinity with GTK, just because it's always been the "libre" option...

In terms of development language - I'm not entirely sure what I'd use at this point for a full application... Neither C or C++ is a particularly attractive option to me. I think C's strengths aren't in application development - and I've done enough C++ to know that I at least wouldn't want it to be the first-pass implementation language for something, unless optimization really was critical. I guess I'd probably do some combination of Python and C++, at least until finding some language I'd be happier with... That being the case I think the native bindings of GTK and QT (C with GObjects versus C++, respectively) don't make much difference - it's more about the other language bindings (Python, Ruby, or compiled languages with a strong object-oriented component...)

I have heard that QT has a richer set of functionality overall than GTK (don't know the details) - and that creating new widgets in QT is easier than in GTK. (Again, don't know the details.) Have also heard that QT startup is a bit slower... Among other things I am interested in writing code that will run well on my netbook - so I want to avoid unnecessary overhead.

<shrug> I should probably just experiment with both - but I thought I'd ask if people can provide any insight or suggestions...

(EDIT): A related question I'm trying to work out is whether I want to integrate with a desktop environment (KDE or GNOME) or just write an X app. I like integration, but I don't always support the UI design principles put forward by the groups curating these environments... Plus there's the desire to not overburden myself or my app with dependencies... <shrug>
---GEC
I want to create a truly new command-line shell for Unix.
Anybody want to place bets on whether I ever get any code written?

qbg
Posts: 586
Joined: Tue Dec 18, 2007 3:37 pm UTC

Re: QT and GTK on Linux, for development...

Postby qbg » Wed Jan 14, 2009 9:00 pm UTC

Qt is a very, very nice library that does a ton of stuff, so I'd think you would need a good reason to use something else. As for startup times, Qt applications startup fast in my experience unless there is something else they have to do before showing the GUI (not that you can't use Qt for non-GUI applications).

User avatar
r1chard
Posts: 281
Joined: Thu Dec 06, 2007 2:17 am UTC
Location: Melbourne, AU
Contact:

Re: QT and GTK on Linux, for development...

Postby r1chard » Wed Jan 14, 2009 9:15 pm UTC

The KDE extensions to Qt are also quite nice in general. I recall that, using PyQt/PyKDE they seemed to be pretty seamlessly integrated.

Rysto
Posts: 1460
Joined: Wed Mar 21, 2007 4:07 am UTC

Re: QT and GTK on Linux, for development...

Postby Rysto » Wed Jan 14, 2009 9:41 pm UTC

If the licensing is a problem for you, you might be interested to know that as of version 4.5(planned to be released this year), Qt will be available under the LGPL.

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: QT and GTK on Linux, for development...

Postby You, sir, name? » Wed Jan 14, 2009 11:07 pm UTC

I dislike how QT tends to take over your project. It wants it's own brand of makefiles and all that sort of stuff that makes me unhappy. I also feel it doesn't play nice with the other libraries.

GTK on the other hand comes with it's own bag of headaches. Object oriented C is painful to use at best (even if it is well implemented) and confusing as hell, but it does the job. Though I feel it turns into a sort of voodoo programming where you really can't tell what's going on under the bonnet, but it appears to do what you tell it to, and you're always asking yourself if you are accomplishing what you're accomplishing because it is how you're supposed to do it, or you've merely accidentally made it work through some obscure undocumented bug/feature that is horribly unstable and only happens on systems compiled when it's full moon and mars is close to jupiter in the night sky.

Is suppose gtkmm would be a good compromise, though I haven't tried that personally.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

User avatar
tetsujin
Posts: 426
Joined: Thu Nov 15, 2007 8:34 pm UTC
Location: Massachusetts
Contact:

Re: QT and GTK on Linux, for development...

Postby tetsujin » Wed Jan 14, 2009 11:24 pm UTC

Rysto wrote:If the licensing is a problem for you, you might be interested to know that as of version 4.5(planned to be released this year), Qt will be available under the LGPL.


Tetsujin wrote:though now QT 4.5 is going to be LGPL so maybe that's not such an issue any more...


Yeah, I noticed. :) That's part of what led to this thread. I had pretty much decided on GTK, largely on the basis of the license, despite my usual affinity toward KDE, and then this news comes out...

You, sir, name? wrote:GTK on the other hand comes with it's own bag of headaches. Object oriented C is painful to use at best (even if it is well implemented) and confusing as hell, but it does the job. Is suppose gtkmm would be a good compromise, though I haven't tried that personally.


Yeah, there is that...

Personally I think the advantages of having GTK written in C (particularly, avoiding issues with C++ ABI) outweigh the disadvantages of that decision - particularly given the fact that I'd prefer not to write the GUI code in C or C++ anyway... I feel like C++ is a better language than C for writing applications - but not by much, really... I'd probably be more inclined toward Objective C at this point, if using a compiled language. But I'd almost certainly start in Python, and then optimize as a second step.
---GEC
I want to create a truly new command-line shell for Unix.
Anybody want to place bets on whether I ever get any code written?

Rysto
Posts: 1460
Joined: Wed Mar 21, 2007 4:07 am UTC

Re: QT and GTK on Linux, for development...

Postby Rysto » Thu Jan 15, 2009 12:08 am UTC

tetsujin wrote:Yeah, I noticed. :) That's part of what led to this thread. I had pretty much decided on GTK, largely on the basis of the license, despite my usual affinity toward KDE, and then this news comes out...

Ah, sorry. I read the line about licensing being a problem for you and stopped reading there.

User avatar
laranzu
Posts: 104
Joined: Fri Nov 30, 2007 4:21 pm UTC
Location: Physical: Canberra, Australia
Contact:

Re: QT and GTK on Linux, for development...

Postby laranzu » Thu Jan 15, 2009 12:38 am UTC

tetsujin wrote:: A related question I'm trying to work out is whether I want to integrate with a desktop environment (KDE or GNOME) or just write an X app. I like integration, but I don't always support the UI design principles put forward by the groups curating these environments... Plus there's the desire to not overburden myself or my app with dependencies... <shrug>


Depends on how tight you want to be "integrated" with the desktop. If you just want cut & paste, drag & drop to work then Qt by itself will do just fine. (Took about a dozen lines of code to allow the user to drop files onto my Qt app.)

As for UI design principles, neither GTK or Qt can really enforce these. You're the programmer: you can arrange the menus and dialogs however you want to.

Qt itself on Linux runs more or less directly on top of raw X, so there are hardly any dependencies.

Hope this helps.

User avatar
r1chard
Posts: 281
Joined: Thu Dec 06, 2007 2:17 am UTC
Location: Melbourne, AU
Contact:

Re: QT and GTK on Linux, for development...

Postby r1chard » Thu Jan 15, 2009 1:15 am UTC

tetsujin wrote:I'd almost certainly start in Python, and then optimize as a second step.

PyQt is the only contender then.

Still waiting to hear that PyQt is going to be re-licensed as LGPL to match Qt since there's now no reason for it to stay GPL.

Then I'm looking forward to the announcement that Qt will replace Tk in the python core :)

User avatar
sparkyb
Posts: 1091
Joined: Thu Sep 06, 2007 7:30 pm UTC
Location: Camberville proper!
Contact:

Re: QT and GTK on Linux, for development...

Postby sparkyb » Thu Jan 15, 2009 2:28 pm UTC

I've done some GTK before, never done QT, and now I actually do most of my GUI (ok, all) programming in Windows. But what I actually wanted to add was another option. What I mostly use and love is the slightly higher level wxWidgets. It has the nice advantage of portability (It works on a lot of platforms). There are bindings for lots of languages (I mostly use wxPython although I've used it from C++ too). Under Linux it will generate GUIs that are based on GTK (because that's what it wraps on that platform) so it is as good as GTK yet I find it much easier to learn and use.

User avatar
tetsujin
Posts: 426
Joined: Thu Nov 15, 2007 8:34 pm UTC
Location: Massachusetts
Contact:

Re: QT and GTK on Linux, for development...

Postby tetsujin » Thu Jan 15, 2009 5:00 pm UTC

laranzu wrote:As for UI design principles, neither GTK or Qt can really enforce these. You're the programmer: you can arrange the menus and dialogs however you want to.


Yeah - it's more when I consider making an actual Gnome or KDE app (to take advantage of... module re-use or something? I don't know) that UI design rules come into play... I don't know to what extent, though.

So if I'm going with Python, why is PyQT the only choice? What about PyGTK?
---GEC
I want to create a truly new command-line shell for Unix.
Anybody want to place bets on whether I ever get any code written?

User avatar
r1chard
Posts: 281
Joined: Thu Dec 06, 2007 2:17 am UTC
Location: Melbourne, AU
Contact:

Re: QT and GTK on Linux, for development...

Postby r1chard » Thu Jan 15, 2009 9:10 pm UTC

tetsujin wrote:So if I'm going with Python, why is PyQT the only choice? What about PyGTK?


http://www.google.com.au/search?q=pyqt+vs+pygtk

Personally I've used PyQt a lot and PyGTK only briefly and quite like PyQt.

User avatar
tetsujin
Posts: 426
Joined: Thu Nov 15, 2007 8:34 pm UTC
Location: Massachusetts
Contact:

Re: QT and GTK on Linux, for development...

Postby tetsujin » Thu Jan 15, 2009 9:15 pm UTC

r1chard wrote:
tetsujin wrote:So if I'm going with Python, why is PyQT the only choice? What about PyGTK?


http://www.google.com.au/search?q=pyqt+vs+pygtk


What, no "letmegooglethatforyou" link? :D

I was just curious about why you said PyQT was the "only contender"...
---GEC
I want to create a truly new command-line shell for Unix.
Anybody want to place bets on whether I ever get any code written?

User avatar
OOPMan
Posts: 314
Joined: Mon Oct 15, 2007 10:20 am UTC
Location: Cape Town, South Africa

Re: QT and GTK on Linux, for development...

Postby OOPMan » Fri Jan 16, 2009 10:07 am UTC

I used PyGTK once. Wrote a simple search crawler tool which ran searches against a certain web site. Anyway, it was threaded so that the interface remained responsive even while the searches were in progress. It all worked fine under Linux, but when I tried to run the app on Windows (The target platform in this case) PyGTK just locked up as soon as the main thread started and the app died. Very useful...
Image

Image

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: QT and GTK on Linux, for development...

Postby Berengal » Fri Jan 16, 2009 10:49 am UTC

Does GTK even run on windows? Unless I've missed something, it's not a portable toolkit.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

sakeniwefu
Posts: 170
Joined: Sun May 11, 2008 8:36 pm UTC

Re: QT and GTK on Linux, for development...

Postby sakeniwefu » Fri Jan 16, 2009 11:26 am UTC

Berengal wrote:Does GTK even run on windows? Unless I've missed something, it's not a portable toolkit.


You
Missed
Something

GTK+ has worked on Windows for ages.

User avatar
OOPMan
Posts: 314
Joined: Mon Oct 15, 2007 10:20 am UTC
Location: Cape Town, South Africa

Re: QT and GTK on Linux, for development...

Postby OOPMan » Fri Jan 16, 2009 1:46 pm UTC

PyGTK and Threading is not so hot though :-)
Image

Image

User avatar
thoughtfully
Posts: 2253
Joined: Thu Nov 01, 2007 12:25 am UTC
Location: Minneapolis, MN
Contact:

Re: QT and GTK on Linux, for development...

Postby thoughtfully » Fri Jan 16, 2009 7:56 pm UTC

OOPMan wrote:PyGTK and Threading is not so hot though :-)

Yeah, I have noticed this. PyQT has intrigued me for a long time (mostly for other reasons, like the Qwt plotting library, and all the nice/elegant features), and now that the licensing is sane, I will probably start switching to it for new projects, although I have tons of investment in PyGTK.
Image
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

sindbad
Posts: 2
Joined: Mon Jan 12, 2009 1:06 pm UTC

Re: QT and GTK on Linux, for development...

Postby sindbad » Sat Jan 17, 2009 5:06 am UTC

Qt's main advantage when using it from python is that it has a native look&feel on all relevant platforms (windows, mac, kde/x11 and even gnome/x11).

There are other things like Phonon, a nicer designer and the sheer mass of functionality, but python duplicates some of it already.

Also, keep in mind that C++ has far fewer ABI issues lately, especially if you stick to one compiler.

User avatar
'; DROP DATABASE;--
Posts: 3284
Joined: Thu Nov 22, 2007 9:38 am UTC
Location: Midwest Alberta, where it's STILL snowy
Contact:

Re: QT and GTK on Linux, for development...

Postby '; DROP DATABASE;-- » Sun Jan 18, 2009 11:18 am UTC

GTK makes it very easy to create ugly interfaces. :P It's not a whole lot harder to make them look nice though.
poxic wrote:You suck. And simultaneously rock. I think you've invented a new state of being.

User avatar
tetsujin
Posts: 426
Joined: Thu Nov 15, 2007 8:34 pm UTC
Location: Massachusetts
Contact:

Re: QT and GTK on Linux, for development...

Postby tetsujin » Mon Jan 19, 2009 12:39 am UTC

'; DROP DATABASE;-- wrote:GTK makes it very easy to create ugly interfaces. :P It's not a whole lot harder to make them look nice though.


How do you think GTK fails in this regard? How could it do better?
---GEC
I want to create a truly new command-line shell for Unix.
Anybody want to place bets on whether I ever get any code written?

User avatar
'; DROP DATABASE;--
Posts: 3284
Joined: Thu Nov 22, 2007 9:38 am UTC
Location: Midwest Alberta, where it's STILL snowy
Contact:

Re: QT and GTK on Linux, for development...

Postby '; DROP DATABASE;-- » Mon Jan 19, 2009 4:53 am UTC

Here's an example. Most of these labels should be left or right-aligned (depending on their position within the container), and could really use some padding. I haven't figured out how to do either of those. Also in Find Patterns, the textboxes don't line up well at all.
gtk.png
gtk.png (75.39 KiB) Viewed 1990 times
I'm sure these things can be fixed with a couple lines (if I could find the API calls to do it), but that's just what I said: it takes a little more work to make them look good.

The real trouble is on Windows, where it doesn't even try to blend in. So you have these nice, sleek, small windows/widgets everywhere else*, and then one GTK app with big ugly ones that don't match the appearance or even colour scheme, and worse, don't even behave the same as literally every other program on the system. (Alt+Numpad, hello? How did they manage to make that not work?) It's rather irritating.
*I'm assuming if you care about appearance, you're using a cool third-party theme. >_>
poxic wrote:You suck. And simultaneously rock. I think you've invented a new state of being.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 5 guests