Delete widgets when a button is clicked
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 .
//add progress bar in a new line
QProgressBar *progress=new QProgressBar(this);
//add delete ToolButton
QToolButton *bt=new QToolButton(this);
//connect delete button to the slot deleteLine to delete the scrollbar and the delete button
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.
I can see two approaches. First, get familiar with QSignalMapper.
Alternatively, make your whole row a single widget, and make it handle its own destruction.