Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyQt: Always on top

Tags:

python

pyqt

This is on PyQt4, Linux and Python 2.5

Can I make PyQt set my window "always on top" over other applications?

For example, in GTK i use the property: Modal.

Now, in PyQt I am using a QWidget, but, I can't find a way to do that.

Any ideas??

like image 883
mRt Avatar asked Dec 17 '09 22:12

mRt


1 Answers

Pass the QMainWindow the WindowStaysOnTopHint window flag (or use setWindowFlags).

As in the name, this is a hint to the windowing manager (not a hard guarantee).

Simplest possible example:

import sys from PyQt4 import QtGui, QtCore  class mymainwindow(QtGui.QMainWindow):     def __init__(self):         QtGui.QMainWindow.__init__(self, None, QtCore.Qt.WindowStaysOnTopHint)  app = QtGui.QApplication(sys.argv) mywindow = mymainwindow() mywindow.show() app.exec_() 
like image 126
ChristopheD Avatar answered Oct 09 '22 04:10

ChristopheD