[Qt-interest] QVBoxLayout whats wrong in this
Anton Chernov
mechernov at gmail.com
Fri Mar 25 10:46:44 CET 2011
Try:
QVBoxLayout *layout = new QVBoxLayout( widget );
layout->addWidget(w1);
layout->addWidget(w2);
widget->show();
return app.exec();
2011/3/25 Sujan Dasmahapatra <sdh at lmwindpower.com>
> #include <QApplication>
>
> #include <QWidget>
>
> #include <QPushButton>
>
> #include <QVBoxLayout>
>
> #include <QPalette>
>
> int main(int argc, char **argv)
>
> {
>
> QApplication app(argc,argv);
>
> QWidget *widget = new QWidget;
>
> widget->resize(500,300);
>
>
>
> QPalette r(widget->palette());
>
> r.setColor(QPalette::Background, Qt::red);
>
> widget->setPalette(r);
>
>
>
>
>
> QWidget *w1 = new QWidget(widget);
>
> w1->resize(300,150);
>
> QPalette p(w1->palette());
>
> p.setColor(QPalette::Background, Qt::green);
>
> w1->setPalette(p);
>
>
>
> QWidget *w2 = new QWidget(widget);
>
> w2->resize(300,150);
>
> QPalette q(w2->palette());
>
> q.setColor(QPalette::Background, Qt::blue);
>
> w2->setPalette(q);
>
>
>
> QVBoxLayout *layout = new QVBoxLayout;
>
> layout->addWidget(w1);
>
> layout->addWidget(w2);
>
>
>
> widget->setLayout(layout);
>
>
>
> widget->show();
>
>
>
> return app.exec();
>
> }
>
>
>
> I am not able to see the distinguished two colored widgets.
>
>
>
>
>
> Kind Regards,
>
>
>
>
>
> *Sujan Dasmahapatra
> *Project Leader, Aero Group
> Aero Group
>
> Tel +91 80 66470248
> Mob
>
> sdh at lmwindpower.com <%25EMAIL%25>
>
>
>
> *LM Wind Power Blades*
>
> lmwindpower.com
>
>
>
> *Together we capture the wind to power a cleaner world*
> ------------------------------
>
>
>
> This e-mail and any attachments are confidential. If you are not the named
> or intended recipient, please notify the sender immediately and do not
> disclose the contents to any other person, use it for any purpose, or store
> or copy the information in any medium. Any unauthorized disclosure, use or
> storage is prohibited and might be unlawful.
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110325/86d79412/attachment.html
More information about the Qt-interest-old
mailing list