PyQt:永远在最前面 [英] PyQt: Always on top
本文介绍了PyQt:永远在最前面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是在 PyQt4、Linux 和 Python 2.5 上的
This is on PyQt4, Linux and Python 2.5
我可以让 PyQt 将我的窗口设置为始终在顶部"吗?
Can I make PyQt set my window "always on top" over other applications?
例如,在 GTK 中,我使用属性:Modal.
For example, in GTK i use the property: Modal.
现在,在 PyQt 中,我使用的是 QWidget,但是,我找不到办法做到这一点.
Now, in PyQt I am using a QWidget, but, I can't find a way to do that.
有什么想法吗??
推荐答案
通过 QMainWindow WindowStaysOnTopHint
窗口标志(或使用 setWindowFlags).
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).
最简单的例子:
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_()
这篇关于PyQt:永远在最前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文