2014-09-03 4 views
-2

저는 Python 및 PySide에서 간단한 응용 프로그램을 작성했습니다. 실행하면 신호가 작동하지 않습니다. 응용 프로그램이 오류없이 시작됩니다.신호가 PySide에서 작동하지 않습니다.

from PySide.QtCore import * 
from PySide.QtGui import * 
import sys 

class Form(QDialog): 

    def __init__(self, parent=None): 
     super(Form, self).__init__(parent) 

     dial = QDial() 
     dial.setNotchesVisible(True) 

     spinbox = QSpinBox() 

     layout = QHBoxLayout() 
     layout.addWidget(dial) 
     layout.addWidget(spinbox) 
     self.setLayout(layout) 

     self.connect(dial, SIGNAL("valueChaged(int)"), spinbox.setValue) 
     self.connect(spinbox, SIGNAL("valueChaged(int)"), dial.setValue) 

     self.setWindowTitle("Signals and Slots") 
    # END def __init__ 
# END class Form 

def main(): 
    app = QApplication(sys.argv) 
    form = Form() 
    form.show() 
    app.exec_() 
# END def main 

if __name__ == '__main__': 
    main() 
# END if 

내가 사용하고 있습니다 :

Pyside 1.2.2; Python 2.7.6; OS Centos; 윈도우 7

내가 가진 응용 프로그램을 실행하고 있습니다 :

숭고한 텍스트 3 이클립스 루나;

신호를 작동 시키려면 어떻게해야합니까?

+0

Btw. 새로운 스타일의 신호 구문 인'dial.valueChanged.connect (spinbox.setValue)'를 사용하면 에러가 발생합니다. – Trilarion

답변

1

신호 이름이 잘못되었습니다.

잘못된 :

valueChaged (int) 

Correct : 그것이 잘 작동

valueChanged (int) 

테스트;

import sys 
from PyQt4.QtGui import * 
from PyQt4.QtCore import * 

class QFormDialog (QDialog): 
    def __init__(self, parent = None): 
     super(QFormDialog, self).__init__(parent) 
     self.myQial = QDial() 
     self.myQSpinbox = QSpinBox() 
     self.myQHBoxLayout = QHBoxLayout() 
     self.myQial.setNotchesVisible(True) 
     self.myQHBoxLayout.addWidget(self.myQial) 
     self.myQHBoxLayout.addWidget(self.myQSpinbox) 
     self.setLayout(self.myQHBoxLayout) 
     self.connect(self.myQial,  SIGNAL('valueChanged(int)'), self.myQSpinbox.setValue) 
     self.connect(self.myQSpinbox, SIGNAL('valueChanged(int)'), self.myQial.setValue) 
     self.setWindowTitle('Signals and Slots') 

if __name__ == '__main__': 
    myQApplication = QApplication(sys.argv) 
    myQFormDialog = QFormDialog() 
    myQFormDialog.show() 
    myQApplication.exec_() 

참고 : PyQt4 & PySide 구현에 동일한 방법입니다.

+1

답변 해 주셔서 감사합니다. 내 실수. – Romulus

관련 문제