Question

Main Qt apps, and AFAIK most KDE apps let you drag windows around not just by their titlebar, but using any empty space on the window. For some reason, a basic Pyqt app like this doesn't appear to let you do that:

from PyQt4.QtGui import *
import sys

a = QApplication(sys.argv)
w = QWidget()
w.show()
sys.exit(a.exec_())

I'm looking to enable dragging the window around by the widgets in it. I found an existing StackOverflow question and answer, but it doesn't use the window manager to actually move the window, which (1) isn't like other apps, (2) isn't as pretty as when the window manager does it.

So my question is, what am I missing? How do I just pass an unused click/drag event up to the window manager for moving the window?

Était-ce utile?

La solution

It turns out that for a window to be draggable by the extra space on it, you need to inherit it from QMainWindow or QDialog, not just QWidget. There you have it.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top