I am not able to understand you clearly..
you open a widget on a button click on main window and should be able to close it and open it again ..thats what you wanted to do ..correct me if i am wrong..