PYQT signal and Slot application examples

Source: Internet
Author: User

First handwritten essay.

Part of the Code for the project:

Change the label of the main form in the child thread.

Class MyForm (Qdialog):
def __init__ (self, Parent=none):
Self.configbox = Myconfigform ()
#configBox为另一个类的实例, connecting to another class, singnal () understands that it defines a name for the signal. Self.set_begin_with is a way to modify the label in this method.
Self.connect (Self.configbox, SIGNAL ("Set_begin_with"), Self.set_begin_with)
  
 
In any of the methods in the Myconfigform class.
def set_begin_with_snormac (self):
Testconfig = testconf ()

if (self.ui.radioButton_7.isChecked ()):
TESTCONFIG.SET_BEGIN_SN ()
# Self.frm_ui.label.setText (U "SN:")
Self.emit (SIGNAL ("Set_begin_with")) #发送名称为set_begin_with signal,
Else
Testconfig.set_beging_mac ()
# Self.frm_ui.label.setText (U "MAC")
Self.emit (SIGNAL ("Set_begin_with"))

Signals and slots are understood as two steps:

1 Connect an instance of another class in the main class. and defines the name of a signal. And the method that is executed after the signal is triggered.
2 in another class, just send this signal. The main class can accept the signal and trigger the signal and execute the method.

In the study, there is something wrong in the place to welcome correct. Thank you

PYQT signal and Slot application examples

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.