[Qt-interest] How to create a QWidget on another QWidget

Colin Kern colin.kern at gmail.com
Fri Feb 13 14:20:46 CET 2009


On Fri, Feb 13, 2009 at 7:00 AM, Ravi_Kalepalli
<Ravi_Kalepalli at satyam.com> wrote:
> Hi
>
>
>
> I wanted to display the QWidget (parent) and again on it another
> QWidget(child).
>
> Like this
>
>
>
>             iWindow = new QWidget(this);
>
>             iWindow->show();
>
>             iWindow->setFixedSize(240,320);
>
>             QPalette pal0(Qt::yellow);
>
>             this->setPalette(pal0);
>
>
>
>             iWindowChild = new QWidget(this);
>
>             iWindowChild->setFixedSize(50,50);
>
>             iWindowChild->show();
>
>             QPalette pal(Qt::red);
>
>             iWindowChild->setPalette(pal);
>
>
>
> Can anyone please help me on this issue, whether this really possible or
> not?
>
>
>
> Regards
>
> Ravi K
>
> ________________________________
> DISCLAIMER:
> This email (including any attachments) is intended for the sole use of the
> intended recipient/s and may contain material that is CONFIDENTIAL AND
> PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
> distribution or forwarding of any or all of the contents in this message is
> STRICTLY PROHIBITED. If you are not the intended recipient, please contact
> the sender by email and delete all copies; your cooperation in this regard
> is appreciated.
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>

The line:

 iWindowChild = new QWidget(this);

should be

iWindowChild = new QWidget(iWindow);

to make iWindowChild a child of the iWindow widget.  You also don't
need to call iWindowChild->show(), since it will inherit visibility
from its parent.


Colin



More information about the Qt-interest-old mailing list