![](/img/trans.png)
[英]Qt - Why can't I trigger mousePressEvent for my custom button in MainWindow
[英]Can't see my label and layout in MainWindow
delete layout();
QGridLayout *gridLayout = new QGridLayout(this);
int cont = 0;
for (Category c : categories) {
cont++;
QVBoxLayout *verticalLayout;
verticalLayout = new QVBoxLayout();
gridLayout->setSpacing(cont);
gridLayout->addLayout(verticalLayout, 0, cont - 1);
QLabel *l;
l = new QLabel();
l->setText(c.getName());
l->setAlignment(Qt::AlignCenter);
verticalLayout->addWidget(l);
}
在mainWindow
,我想补充一个gridLayout
和verticalLayout
使用时的标签for
我的周期categories
您没有将布局设置为任何小部件。 您必须为要应用它的小部件调用函数setLayout(gridLayout) 。 希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.