Qt Toolkit

Qt 4.5 released, still using three year old GCC

Qt 4.5 is out, along with Qt Cre­ator. It’s still using GCC 3.4.5, from a Jan­u­ary 2006 code­base. Sigh.

First thoughts on Qt

I’ve been doing so much C# and XAML cod­ing for work lately, I felt com­pelled to get back to the place I thrive—real C++.

I’ve al­ways been weary of cross-plat­form C++ GUI cod­ing. The op­tions just never seemed very good to me: GTK, which doesn’t act any­thing close to na­tive in Win­dows. Qt, which seemed good but was under GPL. wxWid­gets, which feels like a thin wrap­per around Win32 (and was there­for quite easy for me to learn) but has lots of lit­tle is­sues like the in­abil­ity to scale with DPI. Given the an­nounce­ment of Qt going LGPL, I fig­ured it’s a good time to start learn­ing Qt.

If you’re like me you might be think­ing – “Qt, but that’s not real C++! What hap­pened to using the stan­dard li­brary, tem­plates, and not pay­ing for what you don’t use!?”. Do I wish there was a more mod­ern Boost-qual­ity li­brary? Ab­solutely. But that doesn’t exist. Per­haps be­cause GUI work is rather bor­ing, and coders who could make a bet­ter qual­ity li­brary would rather spend their time on more in­ter­est­ing things. Qt is still the most mod­ern GUI lib I’ve seen for C++ yet. But I di­gress.

Hunt­ing around the Qt web­site, first thing I find out: it’s going to be a pain in the ass to com­pile my Qt-based pro­ject with VC++. I’m sure it’s pos­si­ble with a lit­tle elbow grease, but I wanted to get started quickly so I down­loaded Qt Cre­ator in­stead. Cre­ator has a bun­dle that in­cludes MinGW, Qt, and the Cre­ator IDE. Per­fect for a quick start!

Cre­ator turns out to be a pretty good IDE. It is very close to knock­ing VC++ out of my fa­vorite po­si­tion. With a few bugs and us­abil­ity is­sues fixed, it’s pos­si­ble I’ll be using it even for pure Win32 apps.

I cre­ate a GUI pro­ject, hop into the de­signer and lay out a sim­ple win­dow. I haven’t even read any doc­u­men­ta­tion or tu­to­ri­als for using Qt at this point, so I get a lit­tle stuck. There are no Cre­ator tu­to­ri­als out there yet, so I skimmed through some other Qt stuff and quickly found my way to the lay­out model – ex­actly what I was look­ing for. The best thing I’ve found in WPF is the abil­ity to have a win­dow layed out au­to­mat­i­cally based on the size of con­trols in it, and I’m very pleased to see Qt has some­thing sim­i­lar. Tie in some events, and I have a sim­ple app cre­ated.

Com­pile the pro­ject and oops, some er­rors pop up. After a lit­tle hair pulling, I found out the Cre­ator bun­dle comes with MinGW GCC 3.4 — very old! It was not com­pil­ing some of my stan­dard C++ cor­rectly. I’ll see about in­te­grat­ing TDM’s GCC 4.x builds soon, but fear it will mean re­com­pil­ing Qt. For now I’ve be­grudg­ingly dumbed down my C++ to the sub­set that GCC 3.4 works with.

In one day I’ve learned how to cre­ate a func­tion­ing GUI pro­gram with Qt. I’ve also backed away from the de­signer and learned how to do things man­u­ally – I’ll def­i­nitely use the de­signer for a se­ri­ous pro­ject, but learn­ing how things work be­hind the scenes is im­por­tant too.

All-in-all I’m im­pressed with Qt. It feels na­tive on Win­dows, and has a rel­a­tively clean API. It is more pow­er­ful and pro­duc­tive than straight Win32, but doesn’t seem nearly as pow­er­ful as WPF. Then again, it took me sev­eral months to wrap my head around WPF enough to build any­thing of sub­stance.

Nokia to release Qt under LGPL

This is fan­tas­tic news for any­one de­vel­op­ing GPL-in­com­pat­i­ble soft­ware. Nokia will be re­leas­ing Qt under the LGPL.