PyQt: Always on top

前端 未结 2 1571
终归单人心
终归单人心 2020-12-01 12:24

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

相关标签:
2条回答
  • 2020-12-01 12:55

    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_()
    
    0 讨论(0)
  • 2020-12-01 12:58
    setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
    

    setwindowaFlags is a method that can call it from form object and just take one parameter is a constant QtCore.Qt.WindowStaysOnTopHint that refer to make your form Stays On Top

    0 讨论(0)
提交回复
热议问题