{
systemcounter[j] += 1;
while ((child = vbox->takeAt(0)) != 0){
delete child;
}
for(int i = 0; i<systemcounter[j]; i++){
btnGtr
->setText
(QString("Guitar: %1").
arg(i
+1));
vbox->addWidget(btnGtr);
QObject::connect(btnGtr,
SIGNAL (clicked
()),
this,
SLOT (handleButton
()));
}
mainLayout->addWidget(groupBox);
}
void MyWidget::onaddbutton_clicked()
{
pagecounter += 1;
systemcounter = new int[pagecounter];
systemcounter[pagecounter-1] = 0;
btnTest
->setObjectName
(QString::number(pagecounter
-1));
top->addWidget(groupBox);
top->addWidget(btnTest);
top->maximumSize();
mainLayout->addLayout(top);
groupBox->setLayout(vbox);
connect(btnTest, &QPushButton::clicked, [=] {
emit systembutton_clicked(sender()->objectName().toInt(), groupBox, vbox);
});
}
void MyWidget::systembutton_clicked(int j, QGroupBox *groupBox, QVBoxLayout *vbox)
{
systemcounter[j] += 1;
QLayoutItem *child;
while ((child = vbox->takeAt(0)) != 0){
delete child;
}
for(int i = 0; i<systemcounter[j]; i++){
QPushButton *btnGtr = new QPushButton();
btnGtr->setText(QString("Guitar: %1").arg(i+1));
vbox->addWidget(btnGtr);
QObject::connect(btnGtr, SIGNAL (clicked()), this, SLOT (handleButton()));
}
mainLayout->addWidget(groupBox);
}
void MyWidget::onaddbutton_clicked()
{
pagecounter += 1;
systemcounter = new int[pagecounter];
systemcounter[pagecounter-1] = 0;
QHBoxLayout *top = new QHBoxLayout;
QGroupBox *groupBox = new QGroupBox(tr("&Page %1").arg(pagecounter));
QPushButton *btnTest = new QPushButton("G", this);
btnTest->setObjectName(QString::number(pagecounter-1));
top->addWidget(groupBox);
top->addWidget(btnTest);
top->maximumSize();
mainLayout->addLayout(top);
QVBoxLayout *vbox = new QVBoxLayout;
groupBox->setLayout(vbox);
connect(btnTest, &QPushButton::clicked, [=] {
emit systembutton_clicked(sender()->objectName().toInt(), groupBox, vbox);
});
}
To copy to clipboard, switch view to plain text mode
Bookmarks