解决方法:
scrollArea->setWidgetResizable(true);The widget's autoFillBackground property will be set to true.
如果想要QScrollArea的view widget无背景颜色,只能在setWidget之后调用widget->setAutoFillBackground(false);
scrollArea->setWidget(licenseWidget);
licenseWidget->setAutoFillBackground(false); QString ack = QObject::tr("Sincerely appreciate all the open-source software used.");
QString tmp = QObject::tr("open-source software");
ack = ack.replace(tmp, websiteLinkTemplate.arg(websiteLink).arg(tmp));bool ok = d->licenseDialog != nullptr ? d->licenseDialog->loadLicense() : false;
// 简化后
bool ok = d->licenseDialog && d->licenseDialog->loadLicense(); listView->setAlternatingRowColors(true);通过这种方式获取特定项的数据,不用从数据容器里面遍历每项匹配之后获取。
auto pItem = new DStandardItem(componentInfo->name());
pItem->setData(...);
pItem->data(...);void show()
{
d->listModel->clear();
for (auto component : d->licenseInfo.componentInfos()) {
d->addComponentItem(component);
}
...
}void DLicenseInfoPrivate::clear()
{
qDeleteAll(componentInfos);
componentInfos.clear();
}