Yes, not calling "new" but having it on the heap is the correct way.
In this case, as pointed out, you could just directly pass the SQL string to modal->setQuery(), no need for a QSqlQuery object at all.
You will of course still leak the model if you click that button a second time.
Easily avoidable by not using a local variable but a member and only creating it once, e.g. right in the constructor.
Cheers,
_





Reply With Quote

Bookmarks