Another way to call the dtor is to create the object NOT by a pointer-var like in your case:
...
TransactionDialog *transactionDialog = new TransactionDialog(this, anID, aType);
transactionDialog->show();
...
...
TransactionDialog *transactionDialog = new TransactionDialog(this, anID, aType);
transactionDialog->show();
...
To copy to clipboard, switch view to plain text mode
but as an object directly, like:
...
TransactionDialog transactionDialog(this, anID, aType);
transactionDialog.show();
...
...
TransactionDialog transactionDialog(this, anID, aType);
transactionDialog.show();
...
To copy to clipboard, switch view to plain text mode
That is only if you are not restricted in the way you have to create your object.
I had the same problem on a case with my mainwindow-object in a main.cpp file.
(problem was also solved after i added line 9 for the pointer version)
Here are the two ways that work:
int main(int argc, char *argv[])
{
// FIRST way to reach dtors
CPlotterMainWindow *plotmainwindow = NULL;
plotmainwindow = new CPlotterMainWindow();
plotmainwindow->setAttribute(Qt::WA_QuitOnClose);
plotmainwindow->setAttribute(Qt::WA_DeleteOnClose); // needed to reach dtors
plotmainwindow->show();
// SECOND way to reach dtors
// CPlotterMainWindow plotmainwindow;
// plotmainwindow.setAttribute(Qt::WA_QuitOnClose);
// plotmainwindow.show();
return app.exec();
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// FIRST way to reach dtors
CPlotterMainWindow *plotmainwindow = NULL;
plotmainwindow = new CPlotterMainWindow();
plotmainwindow->setAttribute(Qt::WA_QuitOnClose);
plotmainwindow->setAttribute(Qt::WA_DeleteOnClose); // needed to reach dtors
plotmainwindow->show();
// SECOND way to reach dtors
// CPlotterMainWindow plotmainwindow;
// plotmainwindow.setAttribute(Qt::WA_QuitOnClose);
// plotmainwindow.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Greetings
Bookmarks