PyQt信号传递的方法

1.spinbox 利用valueChanged :

  spinbox.valueChanged.connect(self.on_spin_box_changed)

  def on_spin_box_changed(self,text):

    print ...

2.button 利用clicked:

  button.clicked.connect(self.on_button_clicked)

  def on_button_clicked:

    print ..

3.界面直接利用canceled:

  self.canceled.connect(self.close)

4.treewidget利用clicked:

  self.treewidget.clicked.connect(self.on_tree_widget_clicked)

  def on_tree_widget_clicked(self,qmodelindex):

    item = self.treewidget.currentItem()

    print item.text(n)

5.buttongroup利用buttonClicked[int]:

  self.buttongroup.ubttonClicked[int].connect(self.on_button_clicked)

  def on_button_clicked(self,buttonid):

    button = self.buttongroup.button(buttonid)

    print button.text

6.checkbox利用toggled:

  self.checkbox.toggled.connect(self.checkbox_toggled)

  def checkbox_toggled(self):

    if self.checkbox1.isChecked():

      print...

7.commandlinkbutton利用clicked

  commandlinkbutton.clicked.connect(self.om_button_clicked)

  def on_button_clicked(self):

    commandlinkbutton = self.sender()

    print commandlinkbutton.description()

8.dial利用valueChanged:

  self.dial.valueChanged.connect(self.slider_changed)

  def slider_changed(self):

    print self.dial.value()

9.fontcomobox 利用currentFontchanged:

  fontcombobox.currentFontChanged.connect(self.on_font_changed)

  def on_font_changed(self):

    fontcombobox = self.sender()

    font = fontcombobox.currentFont()

    print font.family()

10.fontDialog利用fontSelected:

  self.fontSelected.connect(self.on_font_selected)

  def on_font_selected(self):

    font = self.currentFont()

    

    print("Name: %s" % (font.family()))
    print("Size: %i" % (font.pointSize()))
    print("Italic: %s" % (font.italic()))
    print("Underline: %s" % (font.underline()))
    print("Strikeout: %s" % (font.strikeOut()))

 

11.lineedit 利用 returnPressed

  self.lineeditreturnPressed.connect(self.return_pressed)

  def return_presed(self):

    print self.lineedit.text()

 

12.listwidget利用clicked:

  self.listwidget.clicked.connect(self.listview_clicked)

  def listview_clicked(self,qmodelindex):

    item = self.listwidget.currentItem()
    print item.text()
13.radiobutton利用toggled:

  radiobutton.toggled.connect(self.on_radio_button_toggled)

  def on_radio_button_toggled(self):

    radiobutton = self.sender()
    if raduibutton.isChecked():
      print radiobutton.country

posted @ 2017-06-29 15:00  陈博凯  阅读(713)  评论(0编辑  收藏  举报