【发布时间】:2016-12-13 00:30:40
【问题描述】:
我有一个用 Pyside 编写的应用程序。我想使用一个复选框让我的应用程序窗口始终显示在顶部。
class RemoteWindow(QtGui.QMainWindow):
"""
This is the main window for the capacitiveRemote which contains the remote
itself for controlling the boxes and shortcuts to starting scripts.
"""
def __init__(self):
super(RemoteWindow, self).__init__()
self.initUI()
这是我的功能
def stayOnTop(self):
if self.checkBoxTop:
self.checkBoxTop.setStyleSheet("color: green")
self.QMainWindow.setWindowFlags(QMainWindow.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
这是复选框
#Stay on the top Checkboxes
self.checkBoxTop = QtGui.QCheckBox('Stay on top', self)
self.checkBoxTop.setMaximumWidth(90)
self.checkBoxTop.setChecked(0)
self.checkBoxTop.clicked.connect(
lambda: self.stayOnTop(),
)
任何帮助将不胜感激。
【问题讨论】:
-
签出PyQt4 : How can i toggle the “Stay On Top” behavior?,忽略“PyQt4”关键字,因为代码也适用于PySide