Hey, Wim

Thanks for point to me about this problem.
First, it's not a typo, it's really an error for me.
And your advice is very good for me, I defined class like this, and all
have this kind of error.

Thanks again for your reply.

-- 
Best regards
Jiongliang Zhang

2010/3/11 Wim Dumon <[email protected]>:
> Hey Jiongliang,
>
> There is something strange about this constructor - probably a typo:
>
> 2010/3/9 Jiongliang Zhang <[email protected]>:
>> class MyWidget : public WContainerWidget
>> {
>> public:
>>        MyWidget(MyServer& server, WContainerWidget *parent = 0)
>>                : WContainerWidget(parent) ,
>>                server_(server) ,
>>                app_(WApplication::instance())
>>        {
>>                WText *sysCmd = new WText("Enter Command: ", parent);
>>                sysCmdEdit_ = new WLineEdit(parent);
>>                sysCmdEdit_->setFocus();
>>
>>                parent->addWidget(new WBreak());
>>                message_ = new WText(parent);
>>
>>                sysCmdEdit_->enterPressed().connect(SLOT(this, 
>> MyWidget::send));
>>
>>                server_.done().connect(SLOT(this, MyWidget::process));
>>                app_->enableUpdates();
>>        }
>>
>
> Wouldn't it make more sense if you replace 'parent' with 'this:
>>                WText *sysCmd = new WText("Enter Command: ", this);
>>                sysCmdEdit_ = new WLineEdit(this);
>>                sysCmdEdit_->setFocus();
>>
>>                this->addWidget(new WBreak());
>>                message_ = new WText(this);
>>
>>                sysCmdEdit_->enterPressed().connect(SLOT(this, 
>> MyWidget::send));
>>
>>                server_.done().connect(SLOT(this, MyWidget::process));
>>                app_->enableUpdates();
>
> If you inherit from WContainerWidget, the internal widgets will
> normally have that object as parent, iso the parent of the
> WContainerWidget. As such, the internal widgets will be deleted if
> MyWidget is deleted, which is probably what you want (same applies to
> hide/show, enable/disable, ...).

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to