实现代码和ui结合布局,怎么实现。。
贴上代码
//测试
//Widget中代码
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
QLabel *a=new myLabel(ui->groupBox);
a->setText("hello");
a->show();
QLabel *b=new myLabel(ui->groupBox);
b->setText("hello");
b->show();
QLabel *c=new myLabel(this);
c->setText("hello");
c->show();
QLabel *d=new myLabel(this);
d->setText("hello");
d->show();
myLabel *e=new myLabel(this);
myLabel *f=new myLabel(this);
QVBoxLayout *l=new QVBoxLayout;
l->addWidget(a);
l->addWidget(b);
l->addWidget(c);
l->addWidget(d);
l->addStretch(2);
ui->groupBox->setLayout(l);
ui->groupBox->show();
}
这样做就是什么都不显示。。。。