我正在从定时器执行的xml中加载数据。 xml被解析并填充到实体对象中。 在一个循环中,从实体对象获取数据并填充QCommandLinkButton's。最后一批按钮被设置在verticalLayout中,然后在scrollArea中。空滚动区域QT C++
但每次加载数据时都会附加到旧数据。如何在重新填充scrollArea之前清空srollArea的内容。
MainWindow::methodExecudedByTimer(){
foreach(int i, map.keys()){
QCommandLinkButton* buttonEmail = new QCommandLinkButton(this);
Email em = map[i];
buttonEmail->setText(em.__toString());
ui->verticalLayout->addWidget(buttonEmail);
}
ui->scrollArea->setLayout(ui->verticalLayout);
}
这是实际添加的东西,如果卡斯帕黑博士打算与回答唯一的答案,他应该标明这是重复的,因为这是一个重复回答。 – snb