和PySid呆在最上面

2024-05-20 19:35:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个用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()

这是我的职责

^{pr2}$

这是复选框

#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(),
        )

任何帮助都将不胜感激。在


Tags: theself应用程序forinitontopclass
1条回答
网友
1楼 · 发布于 2024-05-20 19:35:28
 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")

相关问题 更多 >