Reputation: 537
I have got an app which is written in Pyside. I would like to use a checkbox to my app window show always on the top.
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()
This is my function
def stayOnTop(self):
if self.checkBoxTop:
self.checkBoxTop.setStyleSheet("color: green")
self.QMainWindow.setWindowFlags(QMainWindow.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
This is the checkbox
#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(),
)
Any help would be appreciated.
Upvotes: 1
Views: 1550
Reputation: 537
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")
Upvotes: 3