{
target->setAlignment(original->alignment());
target->setContentsMargins(target->contentsMargins());
target->setHorizontalSpacing(target->horizontalSpacing());
target->setMargin(target->margin());
target->setOriginCorner(original->originCorner());
target->setSizeConstraint(original->sizeConstraint());
target->setSpacing(original->spacing());
target->setVerticalSpacing(original->verticalSpacing());
}
void clone(QGridLayout* original, QGridLayout* target)
{
target->setAlignment(original->alignment());
target->setContentsMargins(target->contentsMargins());
target->setHorizontalSpacing(target->horizontalSpacing());
target->setMargin(target->margin());
target->setOriginCorner(original->originCorner());
target->setSizeConstraint(original->sizeConstraint());
target->setSpacing(original->spacing());
target->setVerticalSpacing(original->verticalSpacing());
}
To copy to clipboard, switch view to plain text mode
void MainWindow::addUnit()
{
if(unitsPerTab[ui->tabWidget->currentIndex()]-48 == 9)
{
return;
}
unitsPerTab[ui->tabWidget->currentIndex()] += 1;
QString prefix
= "unit" + number
+ "_";
unitFrame->setGeometry(1,1,1057,61);
unitFrame->setMaximumHeight(61);
unitFrame->setMaximumWidth(1040);
unitFrame->setMinimumHeight(61);
unitFrame->setMinimumWidth(1040);
unitFrame->setAutoFillBackground(true);
unitFrame
->setFrameShape
(QFrame::Box);
unitFrame
->setFrameShadow
(QFrame::Raised);
unitFrame->setLineWidth(1);
unitFrame->setObjectName(prefix + "frame");
clone(ui->gen_layout, unitLayout);
unitLayout->setObjectName(prefix + "layout");
unitFrame->setLayout(unitLayout);
//...Ommitted for brevity...
unitLayout->addWidget(unitLabels[0],0,0);
for(int i = 1; i < 10; i++)
{
unitLayout->addWidget(unitLabels[i],0,i);
}
unitLayout->addWidget(uSelect,1,0);
unitLayout->addWidget(auth,1,1,Qt::AlignHCenter);
unitLayout->addWidget(spin,1,2,Qt::AlignHCenter);
unitLayout->addWidget(msize,1,3,Qt::AlignHCenter);
unitLayout->addWidget(champ,1,4);
unitLayout->addWidget(banner,1,5);
unitLayout->addWidget(horn,1,6);
unitLayout->addWidget(ubi,1,7,Qt::AlignHCenter);
unitLayout->addWidget(minU,1,8);
unitLayout->addWidget(cost,1,9,Qt::AlignHCenter);
QString layName
= ui
->tabWidget
->currentWidget
()->objectName
() + "_layout";
ui->tabWidget->currentWidget()->findChild<QVBoxLayout*>(layName)->addWidget(unitFrame);
unitFrame->show();
}
void MainWindow::addUnit()
{
if(unitsPerTab[ui->tabWidget->currentIndex()]-48 == 9)
{
return;
}
unitsPerTab[ui->tabWidget->currentIndex()] += 1;
QString number = QString(QChar(unitsPerTab[ui->tabWidget->currentIndex()]));
QString prefix = "unit" + number + "_";
QFrame* unitFrame = new QFrame;
unitFrame->setGeometry(1,1,1057,61);
unitFrame->setMaximumHeight(61);
unitFrame->setMaximumWidth(1040);
unitFrame->setMinimumHeight(61);
unitFrame->setMinimumWidth(1040);
unitFrame->setAutoFillBackground(true);
unitFrame->setFrameShape(QFrame::Box);
unitFrame->setFrameShadow(QFrame::Raised);
unitFrame->setLineWidth(1);
unitFrame->setObjectName(prefix + "frame");
QGridLayout* unitLayout = new QGridLayout();
clone(ui->gen_layout, unitLayout);
unitLayout->setObjectName(prefix + "layout");
unitFrame->setLayout(unitLayout);
//...Ommitted for brevity...
unitLayout->addWidget(unitLabels[0],0,0);
for(int i = 1; i < 10; i++)
{
unitLayout->addWidget(unitLabels[i],0,i);
}
unitLayout->addWidget(uSelect,1,0);
unitLayout->addWidget(auth,1,1,Qt::AlignHCenter);
unitLayout->addWidget(spin,1,2,Qt::AlignHCenter);
unitLayout->addWidget(msize,1,3,Qt::AlignHCenter);
unitLayout->addWidget(champ,1,4);
unitLayout->addWidget(banner,1,5);
unitLayout->addWidget(horn,1,6);
unitLayout->addWidget(ubi,1,7,Qt::AlignHCenter);
unitLayout->addWidget(minU,1,8);
unitLayout->addWidget(cost,1,9,Qt::AlignHCenter);
QString layName = ui->tabWidget->currentWidget()->objectName() + "_layout";
ui->tabWidget->currentWidget()->findChild<QVBoxLayout*>(layName)->addWidget(unitFrame);
unitFrame->show();
}
To copy to clipboard, switch view to plain text mode
Bookmarks