簡體   English   中英

在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 ,我想補充一個gridLayoutverticalLayout使用時的標簽for我的周期categories

您沒有將布局設置為任何小部件。 您必須為要應用它的小部件調用函數setLayout(gridLayout) 希望能幫助到你

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM