That's the way, it works fine now, many thanks.
If this dialog is being created and posted in a slot (say, in response to a button click or something), then the code you have written looks like it will result in a memory leak when the slot exits. If the dialog is meant to be transient (i.e. posted only for the duration of the slot's execution), then the more conventional way is to create the dialog on the stack instead of on the heap through new():
void MainWindow::someSlot()
{
noobsForm myNoobs(driveDataList, file, ui->cboxDevice->currentText());
QObject::connect( this,
SIGNAL(progressUpdate
(int)),
&myNoobs,
SLOT(updateProgress
(int)));
myNoobs.exec();
}
void MainWindow::someSlot()
{
noobsForm myNoobs(driveDataList, file, ui->cboxDevice->currentText());
QObject::connect( this, SIGNAL(progressUpdate(int)), &myNoobs, SLOT(updateProgress(int)));
myNoobs.exec();
}
To copy to clipboard, switch view to plain text mode
In this way, the lifetime of the dialog is the same as the lifetime of the slot; when the slot exits, the "myNoobs" instance on the stack is automatically deleted.
Alternatively, you could use your heap-based method, but add a call to
myNoobs->setAttribute( Qt::WA_DeleteOnClose, true );
myNoobs->setAttribute( Qt::WA_DeleteOnClose, true );
To copy to clipboard, switch view to plain text mode
before calling exec(), which will cause Qt to delete the dialog instance when the dialog is closed.
Bookmarks