使用 PySide 保持 window 的领先地位
Stay window on the top with PySide
我有一个用 Pyside 编写的应用程序。我想在我的应用程序中使用复选框 window 始终显示在顶部。
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(),
)
如有任何帮助,我们将不胜感激。
def stayOntop(self):
if self.checkBoxTop:
self.checkBoxTop.setStyleSheet("color: green")
self.setWindowFlags(self.windowFlags() ^ QtCore.Qt.WindowStaysOnTopHint)
self.show()
else:
self.checkBoxTop.setStyleSheet("color: black")
我有一个用 Pyside 编写的应用程序。我想在我的应用程序中使用复选框 window 始终显示在顶部。
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(),
)
如有任何帮助,我们将不胜感激。
def stayOntop(self):
if self.checkBoxTop:
self.checkBoxTop.setStyleSheet("color: green")
self.setWindowFlags(self.windowFlags() ^ QtCore.Qt.WindowStaysOnTopHint)
self.show()
else:
self.checkBoxTop.setStyleSheet("color: black")