简体   繁体   中英

how to emit two signals in pyqt5

below is a groubox with 3 radio and one push button

so far connecting one widget to slot is fairly easy self.versuch_2_radio.toggled.connect(self.printstuff())

but how can i emit 2 signals to one slot ?

in pseudocode I want to execute self.versuch_2_radio.toggled() and self.select_button.clicked() print('something')

or do I need to create two slots ?

        self.groupbox = qtw.QGroupBox(self)
        # groupbox.setAlignment(qtc.Qt.AlignHCenter)

        vlayout = qtw.QVBoxLayout()
        vlayout.setAlignment(qtc.Qt.AlignHCenter)

        versuch_1_radio = qtw.QRadioButton("toggle1")
        vlayout.addWidget(versuch_1_radio)
        self.versuch_2_radio = qtw.QRadioButton("toggle2")
        vlayout.addWidget(self.versuch_2_radio)
        versuch_3_radio = qtw.QRadioButton("toggle3")
        vlayout.addWidget(versuch_3_radio)
        self.select_button = qtw.QPushButton('select')
        vlayout.addWidget(self.select_button)

        self.groupbox.setLayout(vlayout)

        # hauptlayout
        haupt_layout = qtw.QFormLayout()
        haupt_layout.addRow(benutzer_label)
        haupt_layout.addRow(ueberschrift_label)
        haupt_layout.setVerticalSpacing(40)
        haupt_layout.addRow(self.groupbox)

        self.setLayout(haupt_layout)

  def printstuff(self):
        print("connected")


The logic is only to detect the clicked QPushButton and to verify the status of the QRadioButton in the slot:

self.select_button.clicked.connect(self.printstuff)
def printstuff(self):
    if self.versuch_2_radio.isChecked():
        print("connected")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM