我尝试动态添加更多字段以在我的应用程序中选择多个路径。不幸的是,我无法摆脱某些图标的重叠:
我使用以下代码添加它们:
void SettingsDialog::addPathEdit(QString dir)
{
if (amountPaths > maxAmountPaths) {
showError(tr("Cannot add more than %1 paths").arg(maxAmountPaths));
return;
}
QHBoxLayout *hLayout = new QHBoxLayout();
hLayout->setObjectName("pathLine");
hLayout->setSizeConstraint(QHBoxLayout::SetMinimumSize);
QLineEdit *lineEdit = new QLineEdit(dir);
lineEdit->setMinimumHeight(25);
lineEdit->setObjectName("path");
hLayout->addWidget(lineEdit);
QPushButton *browseButton = new QPushButton(tr("Browse..."));
browseButton->setMinimumHeight(25);
browseButton->setObjectName("browseButton");
hLayout->addWidget(browseButton);
connect(browseButton, SIGNAL(clicked()), this, SLOT(on_browse_button_clicked()));
ui->pathHolderLayout->addLayout(hLayout);
amountPaths++;
}
pathHolderLayout
QVBoxLayout在哪里。
任何帮助表示赞赏。