2016-12-09 2 views
0

私はPysideに書かれているアプリを持っています。私は常に上に表示する私のアプリのウィンドウにチェックボックスを使用したいと思います。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() 

これは、このチェックボックス

#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.QMainWindow.setWindowFlags(QMainWindow.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) 

私の関数です。

+0

[PyQt4を:どのように私は、「滞在トップオン」動作を切り替えることができますか?]のチェックアウト(http://stackoverflow.com/q/4850584/1248974)、コードも作品として「PyQt4」のキーワードを無視PySideで – davedwards

答えて

1
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") 
関連する問題