[Qt-interest] why is this not allowed?
Konrad Rosenbaum
konrad at silmor.de
Sun May 9 18:42:59 CEST 2010
On Friday 07 May 2010, Gabriele Kahlout wrote:
> QGridLayout signupLayout = *loginLayout;
>
> I'd like to reuse exacly the same, but add an extra field.
There is no sensible context for copying layouts and widgets - the system
has no way of knowing whether you want to copy the visual instance, want
another access port to the same widget, or do something completely
different. It also would not know what to do about the widgets/layouts
parent. Hence it is simply not allowed to force you to think sensibly.
Refactor your code. Put that kind of widget into its own class with
appropriate accessors. Or if it is too interwoven into its parent, create a
method that gives you exactly the tree of widgets that you want and call it
whenever you need a copy of that tree.
So ideally your code should look like:
MyWidget *first = new MyWidget;
//...
MyWidget *secondCopy = new MyWidget;
Konrad
> --- unchanged since 25/1/10 ---
> P.S. Unless a notification (LON), please reply either with an answer OR
> with " ACK" appended to this subject within 48 hours. Otherwise, I might
> resend. In(LON, this) ∨ In(48h, TimeNow) ∨ ∃x. In(x, MyInbox) ∧
> IsAnswerTo(x, this) ∨ (In(subject(this), subject(x)) ∧ In(ACK,
> subject(x)) ∧
> ¬IsAnswerTo(x,this)) ⇒ ¬IResend(this).
PS.: please stop these nonsensical appendixes to your mails. Nobody who
still has some common sense will ever follow them. You'll just end up in a
couple of killfiles.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100509/5fb06ac9/attachment.bin
More information about the Qt-interest-old
mailing list