Solved How to close QDockWidget from code?
-
I have an app with a main window and several helper windows displayed in QDockWidgets. I'm trying to implement a menu I can use to toggle whether a particular helper window is visible.
My helper windows are QWidgets placed inside QDockWidgets. I've tried calling
close()
anddeleteLater()
on the QDockWidget (when I select a menu option), but it is not removed from the main window. I've also calledmyDock->setAttribute(Qt::WA_DeleteOnClose);
, but that did not help either.How can I close my dock pane?
-
@kitfox It is interesting why those functions dont work. You may also try to make visibility false. If it doesnt work either, there can be a loop or somthing like that in code. Maybe it is better to share the code with us
-
@kitfox Why don't you use QMenu to show a menu?
-
@Yunus Looks like close() does work. There error was elsewhere in my code.