your destructor is called automatically when your mainwindow object is destroyed. How and where do you create your mainwindow object and how does your destructor looks like? Please paste your code, so we can help you.