[Patch] KTitleWidget

Matthias Kretz kretz at kde.org
Mon May 14 16:10:06 BST 2007


Hi!

On Monday 14 May 2007, Urs Wolfer wrote:
> + * Use it with a layout:
> + * @code
> +KTitleWidget *titleWidget = new KTitleWidget(parent);
> +titleWidget->setLayout(layout);
> + * @endcode
> + *
> + * Use it with a label:
> + * @code
> +KTitleWidget *titleWidget = new KTitleWidget(parent);
> +QLabel *titleLabel = new QLabel(titleLabel);
> +titleLabel->setText(i18n("My Title"));
> +titleWidget->setWidget(titleLabel);

I like the idea, but I don't like the pattern how a widget or layout is set. 
The typical way you add a child widget is to pass a QWidget parent to a 
widget...

In this case you write in the example code:
QLabel *titleLabel = new QLabel(titleLabel);
Which, I guess, does not compile. Should it be 'new QLabel(0)'?

Why not this way:
KTitleWidget *titleWidget = new KTitleWidget(parent);
QLabel *titleLabel = new QLabel(titleWidget);
titleLabel->setText(i18n("My Title"));

It should be possible to implement this by reimplementing childEvent.

And then I'd just get rid of the setLayout function in favor of:
KTitleWidget *titleWidget = new KTitleWidget(parent);
QWidget *frame = new QWidget(titleWidget);
QLayout *layout = new Q...Layout(frame);

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070514/ae6d9183/attachment.sig>


More information about the kde-core-devel mailing list