PDA

View Full Version : Docked Widget Menu



Chuk
3rd June 2007, 20:30
I have an application with multiple docked widgets, opened from a menu. When I right click on a dock title bar, I get a checked menu of opened docks, which can be hidden/shown by selecting them. I'm trying to find a way to get this on a menu in the main window, but can't find anywhere this dock menu is created. I figure if I can it's name, or a function to return a pointer to it, I can can add it to the menu I want. Any suggestions?

I'm also looking for a way to close (delete) the dock when it has been unselected from this menu. I've tried connecting a slot to the visibilityChanged(bool) signal, but this seems to trigger false when moving the dock. Otherwise it works fine. If figure I can fix this problem once I find out how to use the dock menu.

jpn
3rd June 2007, 20:35
I'm trying to find a way to get this on a menu in the main window, but can't find anywhere this dock menu is created.
QMainWindow::createPopupMenu()


I'm also looking for a way to close (delete) the dock when it has been unselected from this menu. I've tried connecting a slot to the visibilityChanged(bool) signal, but this seems to trigger false when moving the dock. Otherwise it works fine. If figure I can fix this problem once I find out how to use the dock menu.
QDockWidget::toggleViewAction()

marcel
3rd June 2007, 20:35
I have an application with multiple docked widgets, opened from a menu. When I right click on a dock title bar, I get a checked menu of opened docks, which can be hidden/shown by selecting them. I'm trying to find a way to get this on a menu in the main window, but can't find anywhere this dock menu is created. I figure if I can it's name, or a function to return a pointer to it, I can can add it to the menu I want. Any suggestions?


See QMainWindow::createPopupMenu() docs. Should be what you need.



I'm also looking for a way to close (delete) the dock when it has been unselected from this menu. I've tried connecting a slot to the visibilityChanged(bool) signal, but this seems to trigger false when moving the dock. Otherwise it works fine. If figure I can fix this problem once I find out how to use the dock menu.


See QDockWidget::toggleViewAction documentation.

Regards

marcel
3rd June 2007, 20:36
QMainWindow::createPopupMenu() (http://doc.trolltech.com/latest/qmainwindow.html#createPopupMenu)

QDockWidget::toggleViewAction() (http://doc.trolltech.com/latest/qdockwidget.html#toggleViewAction)

Damn, you're fast!... :)

Chuk
4th June 2007, 00:33
See QMainWindow::createPopupMenu()

The popup menu is already there, seemingly auto-generated. I did not write code for it. I'm looking for a quick way to get a copy of it, for my menu. I could recreate it, but would then need to handle more docks added as well.

I just realized the "Dock Widgets" example has what I want on the "View" menu. Thats the same as the right click menu on a dock title bar.



See QDockWidget::toggleViewAction documentation.


The existing menu already handles the toggling of a view, I want to actually delete it with removeDockWidget(). Since the app has a number of dockable dialogs, I want to remove closed (hidden) ones. When the app closes, it saves the open docks. When the app opens, it restores the docks. Using isVisible() doesn't seem to work for docks that were hidden, it always returns true as long as the dock has been created. Right now I'm checking for a NULL pointer to the dialog and that seems to be the only thing that works right.

aamer4yu
4th June 2007, 03:56
The popup menu is already there, seemingly auto-generated. I did not write code for it.
yes it is auto generated unless u override it. Just override it, and add the dock widgets which are visible. It will solve ur purpose. Just try overriding the createPopupMenu() function. Read the docs to see more. It returns a pointer to menu.

mqt
3rd July 2013, 14:12
I want to get a handle of that menu and display permanently on the min window menubar. How to do that?