Linked by Thom Holwerda on Tue 1st Dec 2009 19:03 UTC, submitted by poundsmack
Qt Nokia has released the latest version of its cross-platform toolkit Qt, version 4.6. As usual, it comes with a whole slew of improvements and new features, and this time, they even added a new platform into the mix.
Thread beginning with comment 397351
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[3]: KDE
by vivainio on Tue 1st Dec 2009 20:47 UTC in reply to "RE[2]: KDE"
vivainio
Member since:
2008-12-26

In particular, I like how containers (that provide layouts) are widgets themselves, meaning that you can put a complex layout with multiple widgets in it anywhere that you could put a single widget. That's not true in Qt (at least, not without a little extra work): there, layouts are a separate entity from widgets.


I think you may be misunderstanding something here. You can instantiate a QWidget (not subclass, just instantiate), set a layout on it, then add your child widgets there. The resulting QWidget can be used as you would use the layout object in Gtk, i.e. you can add it as a "single" widget to a place that accepts a single widget (e.g. another layout).

You can find 2 source snippets that do just this here:

http://qt.nokia.com/doc/4.6/layout.html#laying-out-widgets-in-code

Of course you could trivially create your QVBoxWidget that does what you want (i.e. avoid the single setLayout call), but I think you'll agree that it wouldn't really help things :-).

Reply Parent Score: 4

RE[4]: KDE
by boldingd on Tue 1st Dec 2009 21:07 in reply to "RE[3]: KDE"
boldingd Member since:
2009-02-19

While that is true, something about that approach just doesn't sit with me: I find treating containers as widgets to be more... elegant and orthogonal, I suppose. I think that model is just more elegant and flexible, and is easier for me to keep track of and reason about.

Reply Parent Score: 2

RE[5]: KDE
by vivainio on Tue 1st Dec 2009 21:36 in reply to "RE[4]: KDE"
vivainio Member since:
2008-12-26

While that is true, something about that approach just doesn't sit with me: I find treating containers as widgets to be more... elegant and orthogonal, I suppose.


QWidgets are containers are widgets. The layout (given by setLayout) just specifies how they should be sorted inside the container.

I don't know if either way is better/worse than the other. I guess the Gtk way involves one moving part less, but the difference is negligible (i.e. I feel like we are bikeshedding here ;-).

Reply Parent Score: 5