[Qt-interest] Catch floating dock windows
Ole Streicher
ole-usenet-spam at gmx.net
Mon May 18 10:19:24 CEST 2009
Hi,
I have an application that uses mainly QDockWidgets (no central widget
at all) to provide an eclipse-like style.
I now want to implement the following behaviour: If the user moves the
dock widget out of the main window, a new main window shall be created
and the dock widget shall be added to the new main window.
In my program, this is implemented with the topLevelChanged(bool)
signal. It works, if one just clicks the diamond button of the dock
widget. But if one tries to move the dock widget with the mouse, the
signal is emitted already during the move, and I get immediately a
segmentation fault.
The code I use (in Python, but it is probably not a PyQt4 related problem):
------------------------------8<-------------------------------------
from PyQt4 import QtGui, QtCore
class DockWindow(QtGui.QDockWidget):
def __init__(self, widget, parent):
QtGui.QDockWidget.__init__(self, parent)
self.parent = parent
self.setAllowedAreas(QtCore.Qt.TopDockWidgetArea)
self.setFocusPolicy(QtCore.Qt.StrongFocus)
self.setWidget(widget)
parent.addDockWidget(QtCore.Qt.TopDockWidgetArea, self)
self.connect(self,
QtCore.SIGNAL('topLevelChanged(bool)'),
self.top_level_changed)
def top_level_changed(self, toplevel):
if toplevel:
self.parent = AppWindow(self.parent.app)
self.parent.addDockWidget(QtCore.Qt.TopDockWidgetArea, self)
self.parent.show()
------------------------------8<-------------------------------------
How can I get the dock widget decorated in case one moves it from its
parent?
Best regards
Ole
More information about the Qt-interest-old
mailing list