- Create Layout:
void Schedule::createLayout()
{
mainLayout->addWidget(viewport);
Token *label = new Token(this);
label->setAlignment(Qt::AlignLeft);
QList<Token *> cwList;
cwList.append(label);
daysLayout->addWidget(label);
for (int i = 0; i < 5; i++ )
{
Button *label = new Button(this);
label->setAlignment(Qt::AlignLeft);
label->setOptimumSize(299, 15);
SchedulesList.append(label);
daysLayout->addWidget(label);
}
daysLayout->setSpacing(1);
daysLayout->setContentsMargins(0,0,0,0);
daysLayout->setAlignment(Qt::AlignCenter);
viewport->setLayout(daysLayout);
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0,0,0,0);
mainLayout->setAlignment(Qt::AlignCenter);
setLayout(mainLayout);
}
void Schedule::createLayout()
{
QVBoxLayout *mainLayout = new QVBoxLayout();
QGridLayout *daysLayout = new QGridLayout();
QWidget *viewport = new QWidget();
mainLayout->addWidget(viewport);
Token *label = new Token(this);
label->setAlignment(Qt::AlignLeft);
QList<Token *> cwList;
cwList.append(label);
daysLayout->addWidget(label);
for (int i = 0; i < 5; i++ )
{
Button *label = new Button(this);
label->setAlignment(Qt::AlignLeft);
label->setOptimumSize(299, 15);
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
SchedulesList.append(label);
daysLayout->addWidget(label);
}
daysLayout->setSpacing(1);
daysLayout->setContentsMargins(0,0,0,0);
daysLayout->setAlignment(Qt::AlignCenter);
viewport->setLayout(daysLayout);
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0,0,0,0);
mainLayout->setAlignment(Qt::AlignCenter);
setLayout(mainLayout);
}
To copy to clipboard, switch view to plain text mode
- i want update layout can show and hide button.
i use:
for (int i = 0; i < 5; i++)
{
Item = daysLayout->itemAt(i);
if (Item)
{
Item->widget()->hide();
Item->widget()->adjustSize();
Item->widget()->updateGeometry();
}
}
daysLayout->update();
QLayoutItem *Item = NULL;
for (int i = 0; i < 5; i++)
{
Item = daysLayout->itemAt(i);
if (Item)
{
Item->widget()->hide();
Item->widget()->adjustSize();
Item->widget()->updateGeometry();
}
}
daysLayout->update();
To copy to clipboard, switch view to plain text mode
But i can't show them again.
How to do this??
Many thank!!!
Bookmarks