When add button is clicked a Progresss bar and a delete button are added to a scollarea in a new line and when delete button is clicked the whole line (progress bar and delete button) must be deleted .
int nb=1;
void on_AddButton_clicked()
{
//add progress bar in a new line
QProgressBar *progress=new QProgressBar(this);
progress->setObjectName("p"+QString::number(nb));
//add delete ToolButton
QToolButton *bt=new QToolButton(this);
bt->setObjectName("bt"+QString::number(nb));
bt->setIcon(QIcon(":/new/images/images/cancel.png"));
bt->setIconSize(QSize(40,40));
bt->setAutoRaise(true);
//connect delete button to the slot deleteLine to delete the scrollbar and the delete button
connect(bt,SIGNAL(clicked()),this,SLOT(deleteLine()));
grid->addWidget(progress,nb,1);
grid->addWidget(bt,nb,2);
ui->scroll->setLayout(grid);
nb++;
}
The problem is that I don’t know the number of the line where the delete button is clicked and i have a problem with the slot deleteLine it doesn’t seem to work.
↧