I'm currently writing a qt application with docking windows. Basically, I want to modify my state variables from the docking window. I have already created the window, but when I close my application I get a segFault because I haven't connected it to any closing signal, and it is currently also disconnected to the parent window.
Has anybody any experience with docking windows and can paste some code for either
- how to connect the docking window to the parent so it gets automatically closed when the parent is closed
- how to correctly close the docking window once the main window gets closed
I don't have time to paste code for you right now, but I can try to assist. First, Sigma's suggestion of trying the sample apps is a very good one. Qt has great sample apps. Just do a grep for QDockWidget (or QDockWindow if you're using Qt3) in the examples folder.
Moving on, you shouldn't segfault for not connecting a signal. Furthermore, the docking window should go away automatically when the parent is closed. That's part of Qt's hierarchy.
What I'm guessing may be your issue is being unaware of Qt's memory management. Qt main windows don't automatically clean up, so general suggestion is to put them on the stack. However, all other Qt widgets that are parented do clean up, so generally put them on the heap and Qt will do the cleanup behind the scenes. Your issue may be more related to something of that flavor. I know it threw me off at first that Qt was actually automatically cleaning up and deallocating the other widgets that were no longer used.
Finally, one other tip that QDockWidgets only work properly, in my experience, when the parent is a QMainWindow (or derivative). This is another thing that threw me off at first.
Let me know if that helps. If not, clarify what issues you're having and I'll see what else I can advise.