[PyQt] QDockWidget issue in Linux, but not Windows, OSX

Hans-Peter Jansen hpj at urpla.net
Fri Feb 10 23:56:21 GMT 2012


On Friday 10 February 2012, 21:42:52 JPolk wrote:
> Here is a simplified example of the bug...
>
> Again, this behaviour only happens in Linux, not WinXP or
> OSX...Anybody have any idea or thoughts on this?

This is most probably due to differences in window manager behavior, 
that Qt tries (hard) to cover. It _might_ also be a bug. I don't know. 

Anyway, if you use dock widgets the usual way, they _do_ work properly 
with Linux:

#!/usr/bin/python

import sys
from PyQt4 import QtGui, QtCore

app = QtGui.QApplication(sys.argv)
# Window
win = QtGui.QMainWindow()
win.setWindowTitle("Test")
win.resize(400,300)
win.show()
# Dock
dock = QtGui.QDockWidget(win) 
dock.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea)
dock.setGeometry(0,0,400,300)
win.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dock)
sys.exit(app.exec_())

BTW, yours was movable, too. Just hold Alt down during move. I guess, 
with a little window flag trickery _after_ undocking, the desired 
effects could be archived, too.

Cheers,
Pete

> #====================================================================
>=========
>
> #!/usr/bin/python
>
> # On linux, when you undock the widget, the resulting window can't be
> moved (only resized).
> #
>
> import sys
> from PyQt4 import QtGui, QtCore
>
> app = QtGui.QApplication(sys.argv)
> # Window
> win = QtGui.QWidget()
> win.setWindowTitle("Test")
> win.resize(400,300)
> win.show()
> # Dock
> dock = QtGui.QDockWidget(win)
> dock.setFeatures(QtGui.QDockWidget.DockWidgetFloatable |
> QtGui.QDockWidget.DockWidgetClosable |
> QtGui.QDockWidget.DockWidgetMovable ) dock.setGeometry(0,0,400,300)
> dock.show()
> sys.exit(app.exec_())
>
> #====================================================================
>=========
>
>
> The Linux Env
> Centos 5.7
> Python 2.6.6
> Qt 4.7.4      (qt-everywhere-opensource-src-4.7.4.tar.gz)
> Sip 4.13.1
> PyQt 4.9    (PyQt-x11-gpl-4.9.tar.gz)
>
> Thank you,
>
>
>
> --
> View this message in context:
> http://python.6.n6.nabble.com/QDockWidget-issue-in-Linux-but-not-Wind
>ows-OSX-tp4374122p4384646.html Sent from the PyQt mailing list archive
> at Nabble.com.
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt




More information about the PyQt mailing list