Solved Closing an instance of QMainWindow?
-
I want to programmatically close an instance of QMainWindow, I have a pointer to the widget associated with the window and I've tried calling the close function, it doesn't close the window and it remains visible.
I've also tried casting the widget pointer to QMainWindow:
QMainWindow* pobjWindow = static_cast<QMainWindow*>(pobjWidget); pobjWindow->close();
I've single stepped this in the debugger to verify the pointer isn't nullptr, it doesn't close.
-
Hi,
Maybe a silly question but: are you sure you are closing the instance you think you are closing ?
By the way, you should rather use qobject_cast.
-
Hi,
Maybe a silly question but: are you sure you are closing the instance you think you are closing ?
By the way, you should rather use qobject_cast.
-
@SGaist , I was just about to delete this post as you are perfectly correct, I was closing a different window.
-
Hi
Please dont delete posts.
Just flag it as solved.