Whether Dialog window's object's memory is leaking or not ?
-
void MainWindow::on_pushButton_clicked() { toDoList = new Dialog(this); toDoList->exec(); int code = toDoList->result(); // print dialog code returned switch(code){ case 0: qDebug()<< "Rejected Dialog code is returned "<<Qt::endl; break; case 1: qDebug()<< "Accepted Dialog code is returned "<< Qt::endl; break; default: qDebug()<< "Nothing is return form Dialog Window"<< Qt::endl; } }I just want to know if Somewhere ; memory is leaking or not of dialog window object because i am not deleting it before function return because. Thanks for you valuable reply in advance.
-
void MainWindow::on_pushButton_clicked() { toDoList = new Dialog(this); toDoList->exec(); int code = toDoList->result(); // print dialog code returned switch(code){ case 0: qDebug()<< "Rejected Dialog code is returned "<<Qt::endl; break; case 1: qDebug()<< "Accepted Dialog code is returned "<< Qt::endl; break; default: qDebug()<< "Nothing is return form Dialog Window"<< Qt::endl; } }I just want to know if Somewhere ; memory is leaking or not of dialog window object because i am not deleting it before function return because. Thanks for you valuable reply in advance.
It does not leak, it's cleaned up when MainWindow gets destroyed as described in the documentation.
-
void MainWindow::on_pushButton_clicked() { toDoList = new Dialog(this); toDoList->exec(); int code = toDoList->result(); // print dialog code returned switch(code){ case 0: qDebug()<< "Rejected Dialog code is returned "<<Qt::endl; break; case 1: qDebug()<< "Accepted Dialog code is returned "<< Qt::endl; break; default: qDebug()<< "Nothing is return form Dialog Window"<< Qt::endl; } }I just want to know if Somewhere ; memory is leaking or not of dialog window object because i am not deleting it before function return because. Thanks for you valuable reply in advance.
Hi and welcome to devnet,
Your not deleting it at all so yes the memory use will increase until MainWindow is deleted.
Create your dialog on the stack, the way you use it does not justify to use the heap.