[PyQt] Always on top on windows
Mads Ipsen
mpi at comxnet.dk
Tue Jan 5 15:57:01 GMT 2010
When I launch a QWidget from another widget as
window_flags = QtCore.Qt.WindowFlags() | QtCore.Qt.Window
self._widget = QtGui.QWidget(self, QtCore.Qt.Window)
self._widget.show()
where self is a class inheriting from QWidget, the new widget has self
as parent but appears in a separate window with its own frame etc.
* On Linux, the parent and child can be active completely independent of
other.
* On XP, the child is always on top of the parent window.
The XP behavior is dead annoying. Any suggestions on how to get rid of tis'?
Best regards,
Mads
Minimal example app included below:
import sys
from PyQt4 import QtCore, QtGui
class Widget(QtGui.QWidget):
def __init__(self, parent=None, window_flags=QtCore.Qt.WindowFlags()):
QtGui.QWidget.__init__(self, parent, window_flags)
# Add layuot
layout = QtGui.QVBoxLayout(self)
self.setLayout(layout)
# Add a push button
self._push_button = QtGui.QPushButton('Push me')
layout.addWidget(self._push_button)
# Connect it
self.connect(self._push_button, QtCore.SIGNAL('clicked()'),
self.clicked)
def clicked(self):
window_flags = QtCore.Qt.WindowFlags() | QtCore.Qt.Window
self._widget = QtGui.QWidget(self, QtCore.Qt.Window)
self._widget.show()
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
widget = Widget()
widget.show()
sys.exit(app.exec_())
--
+-------------------------------------------------------------+
| Mads Ipsen, Scientific developer |
+-------------------------------+-----------------------------+
| QuantumWise A/S | phone: +45-29716388 |
| Nørre Søgade 27A | www: www.quantumwise.com |
| DK-1370 Copenhagen K, Denmark | email: mpi at quantumwise.com |
+-------------------------------+-----------------------------+
More information about the PyQt
mailing list