Search code examples
pythonpyqt6

Getting value from a QSpinBox from one class to another


I designed a ui with qt designer, I have a QSpinBox in a class that I need to get its value from another class but instead, I get this <function class.fun at 0x0000028549B1DEE0> when I print it. When I try to print in the same class it works, please help

Code:

class Ui_Form(object):
    row = 1

    def setupUi(self, Form):
        
    --> self.repeat_2 = QtWidgets.QSpinBox(Form)
        self.repeat_2.setGeometry(QtCore.QRect(390, 310, 121, 51))
        self.repeat_2.setFont(font)
        self.repeat_2.setMinimum(1)
        self.repeat_2.setMaximum(1000000000)
        self.repeat_2.setObjectName("repeat_2")
        
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "E-aalim Google Maps"))
        self.strt_btn.setText(_translate("Form", "Start"))
        self.label_2.setText(_translate("Form", "Copyrights ©LorD OmaR®"))
        self.label_3.setText(_translate("Form", "Version 1.1"))
        self.email_choice.setCurrentText(
            _translate("Form", "[email protected]"))
        self.email_choice.setItemText(0,
                                      _translate("Form", "[email protected]"))
        self.email_choice.setItemText(1, _translate("Form",
                                                    "eaalim-comentarista@eaalim-blogs-commenter.iam.gserviceaccount.com"))
        self.warn.setText(_translate("Form", "-Make Sure To Share This Email With The Sheet-"))
        self.title.setText(_translate("Form", "E-aalim Google Maps"))
        self.repeat.setText(_translate("Form", "Repeat:"))
        self.strt_row.setText(_translate("Form", "Start Row:"))

    def asd(self):
        print(self.repeat_2.value())


class class2:
    Ui_Form.asd

Solution

  • Try:

    class class2(QtWidgets.QWidget):
        def __init__(self):
            super().__init__()
    
            self.ui = Ui_Form()
            self.ui.setupUi(self)
            self.uiForm.asd()