Tuesday, August 18, 2009

Fascinated in Qt

I just read some about Qt and soon started fascinated in it. Since the main part of Qt is GUI framework the functionalities Qt offers are roughly the same as wx, if there is on in wx, there's an equivalent in qt (roughly, again). What I am interested is its direct use of C++ methods in a simple and flexible way. wx has event objects, multiple 'bind' types and multiple macros to bind events to callbacks. Qt does it in only two macros, signal, slot, and one method QObject::connect(). It is easy to connect a single event to multiple callbacks, multiple events to a single callback, the programmer doesn't have to be aware of thread, It's so flexible that it can be used in many ways. I looked at Qt WebKit API and found Qt has excellently integrated WebKit, which would have been very difficult if there was no signal-slot mechanism flexibility. Since it doesn't restrict the number and types of arguments of the callbacks, it can be well used for callback type network programming.

I think there's one minor drawback. In wx, what and when wx emits an event is usually explicit in the document. In Qt, the user can easily emits an event so it is not as easy as wx (it's a trade-off). It is also explicit for the events Qt itself emits, but the information is scattered in the document. In wx there's little chance to miss an event type and timing being emit once you get used to reading the document. (if not, read through Event handling overview (Don't miss the difference of event propagation mechanism between command events and other) then 'Events' section of Classes by category. See what kind of events there are in wx, then read the 'Event handling' section of the document of specific window you use, such as wxTextCtrl.)


Drake said...

To mimic the single/slot mechanism of Qt in Wx, you can make use of PubSub (http://wiki.wxpython.org/PubSub) or evtmgr, especially the later to mix the wxPython's default binding stuff with signals.

hohehohe2 [at] gmail.com said...

Thanks for the info!