{
systemcounter += 1;
while ((child = vbox->takeAt(0)) != 0){
delete child;
}
for(int i = 0; i<systemcounter; 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;
top->addWidget(groupBox);
top->addWidget(btnTest);
top->maximumSize();
mainLayout->addLayout(top);
groupBox->setLayout(vbox);
for(int i = 0; i<pagecounter; i++){
connect(btnTest, &QPushButton::clicked, [=] {
emit systembutton_clicked(&groupBox[i], vbox, i);
});
signalMapper->setMapping(btnTest, i);
}
}
void MyWidget::systembutton_clicked(QGroupBox *groupBox, QVBoxLayout *vbox, int k)
{
systemcounter += 1;
QLayoutItem *child;
while ((child = vbox->takeAt(0)) != 0){
delete child;
}
for(int i = 0; i<systemcounter; 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;
QHBoxLayout *top = new QHBoxLayout;
QGroupBox *groupBox = new QGroupBox[pagecounter];
QPushButton *btnTest = new QPushButton("G", this);
top->addWidget(groupBox);
top->addWidget(btnTest);
top->maximumSize();
mainLayout->addLayout(top);
QVBoxLayout *vbox = new QVBoxLayout;
groupBox->setLayout(vbox);
signalMapper = new QSignalMapper();
for(int i = 0; i<pagecounter; i++){
connect(btnTest, &QPushButton::clicked, [=] {
emit systembutton_clicked(&groupBox[i], vbox, i);
});
signalMapper->setMapping(btnTest, i);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks