RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 1600923
Accepted
Таня Мамоля
Таня Мамоля
Asked:2024-11-26 23:26:13 +0000 UTC2024-11-26 23:26:13 +0000 UTC 2024-11-26 23:26:13 +0000 UTC

如何将变量从一个类传递到另一个类?

  • 772

需要Stol()将字段中的输入值从类中传递到类中Zakaz()并输出到label_6(也在类中Zakaz())

from PyQt6.QtWidgets import *
from стол import Ui_Form as Ui_Form2
from заказ import Ui_Form as Ui_Form3
class Stol(QMainWindow):
    def __init__(self):
        super().__init__()

        self.ui = Ui_Form2()
        self.ui.setupUi(self)
        self.stol = self.ui.lineEdit
        self.ui.pushButton.clicked.connect(self.btn)


    def btn(self):
        self.st = self.stol.text() #переформотировала введеное число в текст
        print(self.st)
        self.main_window = Zakaz()
        self.main_window.show()
        self.hide()
       

class Zakaz(QMainWindow):
    def __init__(self):
        super().__init__()

        self.ui = Ui_Form3()
        self.ui.setupUi(self)
        #self.sto = self.st #здесь в теории хочу записать данные из другого класса
        #print(self.st)

        self.ui.label_6.setText(???) #что сюда писать
    

if __name__ == "__main__":
    app = QApplication([])
    window = Stol()
    window.show()
    app.exec()

用户界面_Form2

from PyQt6 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(685, 465)
        Form.setStyleSheet("background-color: rgb(213, 213, 213);")
        self.label = QtWidgets.QLabel(parent=Form)
        self.label.setGeometry(QtCore.QRect(130, 80, 501, 71))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(28)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.pushButton = QtWidgets.QPushButton(parent=Form)
        self.pushButton.setGeometry(QtCore.QRect(220, 340, 261, 51))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(12)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.pushButton.setFont(font)
        self.pushButton.setStyleSheet("background-color: rgb(189, 189, 189);")
        self.pushButton.setObjectName("pushButton")
        self.lineEdit = QtWidgets.QLineEdit(parent=Form)
        self.lineEdit.setGeometry(QtCore.QRect(90, 200, 501, 71))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.lineEdit.setFont(font)
        self.lineEdit.setObjectName("lineEdit")

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.label.setText(_translate("Form", "Введите номер стола"))
        self.pushButton.setText(_translate("Form", "Перейти к заказу"))

用户界面_Form3

from PyQt6 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(1106, 884)
        Form.setStyleSheet("\n"
"background-color: rgb(213, 213, 213);\n"
"")
        self.label = QtWidgets.QLabel(parent=Form)
        self.label.setGeometry(QtCore.QRect(0, -10, 1111, 31))
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(parent=Form)
        self.label_2.setGeometry(QtCore.QRect(-20, 30, 1111, 31))
        self.label_2.setObjectName("label_2")
        self.label_3 = QtWidgets.QLabel(parent=Form)
        self.label_3.setGeometry(QtCore.QRect(10, 10, 131, 31))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.pushButton = QtWidgets.QPushButton(parent=Form)
        self.pushButton.setGeometry(QtCore.QRect(500, 110, 171, 101))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.pushButton.setFont(font)
        self.pushButton.setStyleSheet("background-color: rgb(193, 193, 193);")
        self.pushButton.setObjectName("pushButton")
        self.pushButton_2 = QtWidgets.QPushButton(parent=Form)
        self.pushButton_2.setGeometry(QtCore.QRect(690, 110, 171, 101))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.pushButton_2.setFont(font)
        self.pushButton_2.setStyleSheet("background-color: rgb(193, 193, 193);")
        self.pushButton_2.setObjectName("pushButton_2")
        self.pushButton_3 = QtWidgets.QPushButton(parent=Form)
        self.pushButton_3.setGeometry(QtCore.QRect(880, 110, 171, 101))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.pushButton_3.setFont(font)
        self.pushButton_3.setStyleSheet("background-color: rgb(193, 193, 193);")
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_4 = QtWidgets.QPushButton(parent=Form)
        self.pushButton_4.setGeometry(QtCore.QRect(500, 230, 171, 101))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.pushButton_4.setFont(font)
        self.pushButton_4.setStyleSheet("background-color: rgb(193, 193, 193);")
        self.pushButton_4.setObjectName("pushButton_4")
        self.pushButton_5 = QtWidgets.QPushButton(parent=Form)
        self.pushButton_5.setGeometry(QtCore.QRect(690, 230, 171, 101))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.pushButton_5.setFont(font)
        self.pushButton_5.setStyleSheet("background-color: rgb(193, 193, 193);")
        self.pushButton_5.setObjectName("pushButton_5")
        self.pushButton_6 = QtWidgets.QPushButton(parent=Form)
        self.pushButton_6.setGeometry(QtCore.QRect(880, 230, 171, 101))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.pushButton_6.setFont(font)
        self.pushButton_6.setStyleSheet("background-color: rgb(193, 193, 193);")
        self.pushButton_6.setObjectName("pushButton_6")
        self.line = QtWidgets.QFrame(parent=Form)
        self.line.setGeometry(QtCore.QRect(471, 100, 16, 771))
        self.line.setFrameShape(QtWidgets.QFrame.Shape.VLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
        self.line.setObjectName("line")
        self.label_4 = QtWidgets.QLabel(parent=Form)
        self.label_4.setGeometry(QtCore.QRect(10, 110, 201, 31))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.line_2 = QtWidgets.QFrame(parent=Form)
        self.line_2.setGeometry(QtCore.QRect(0, 90, 1091, 16))
        self.line_2.setFrameShape(QtWidgets.QFrame.Shape.HLine)
        self.line_2.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
        self.line_2.setObjectName("line_2")
        self.label_5 = QtWidgets.QLabel(parent=Form)
        self.label_5.setGeometry(QtCore.QRect(10, 60, 71, 31))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(12)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.tableWidget = QtWidgets.QTableWidget(parent=Form)
        self.tableWidget.setGeometry(QtCore.QRect(10, 150, 451, 721))
        self.tableWidget.setObjectName("tableWidget")
        self.tableWidget.setColumnCount(0)
        self.tableWidget.setRowCount(0)
        self.label_6 = QtWidgets.QLabel(parent=Form)
        self.label_6.setGeometry(QtCore.QRect(170, 10, 131, 31))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label_6.setFont(font)
        self.label_6.setStyleSheet("background-color: rgb(226, 226, 226);")
        self.label_6.setText("")
        self.label_6.setObjectName("label_6")
        self.label_7 = QtWidgets.QLabel(parent=Form)
        self.label_7.setGeometry(QtCore.QRect(100, 60, 571, 31))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label_7.setFont(font)
        self.label_7.setStyleSheet("background-color: rgb(226, 226, 226);")
        self.label_7.setText("")
        self.label_7.setObjectName("label_7")
        self.label_8 = QtWidgets.QLabel(parent=Form)
        self.label_8.setGeometry(QtCore.QRect(230, 110, 131, 31))
        font = QtGui.QFont()
        font.setFamily("Palatino Linotype")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.label_8.setFont(font)
        self.label_8.setStyleSheet("background-color: rgb(226, 226, 226);")
        self.label_8.setText("")
        self.label_8.setObjectName("label_8")
        self.line.raise_()
        self.label_2.raise_()
        self.label.raise_()
        self.label_3.raise_()
        self.pushButton.raise_()
        self.pushButton_2.raise_()
        self.pushButton_3.raise_()
        self.pushButton_4.raise_()
        self.pushButton_5.raise_()
        self.pushButton_6.raise_()
        self.label_4.raise_()
        self.line_2.raise_()
        self.label_5.raise_()
        self.tableWidget.raise_()
        self.label_7.raise_()
        self.label_6.raise_()
        self.label_8.raise_()

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Оформление заказа"))
        self.label.setText(_translate("Form", "------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"))
        self.label_2.setText(_translate("Form", "------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"))
        self.label_3.setText(_translate("Form", "Стол №"))
        self.pushButton.setText(_translate("Form", "завтрак"))
        self.pushButton_2.setText(_translate("Form", "холодное"))
        self.pushButton_3.setText(_translate("Form", "горячее"))
        self.pushButton_4.setText(_translate("Form", "суп"))
        self.pushButton_5.setText(_translate("Form", "выпечка"))
        self.pushButton_6.setText(_translate("Form", "десерт"))
        self.label_4.setText(_translate("Form", "Состав заказа:"))
        self.label_5.setText(_translate("Form", "кассир:"))
python
  • 1 1 个回答
  • 22 Views

1 个回答

  • Voted
  1. Best Answer
    S. Nick
    2024-11-27T01:17:23Z2024-11-27T01:17:23Z

    将导入更改为您自己的导入并尝试。

    或者:

    主要.py

    '''
    from PyQt6.QtWidgets import *
    from PyQt6 import QtCore, QtGui, QtWidgets
    '''
    import sys
    from PyQt5 import QtCore, QtGui, QtWidgets
    from PyQt5.Qt import *
    
    #from стол import Ui_Form as Ui_Form2
    class Ui_Form2(object):
        def setupUi(self, Form):
            Form.setObjectName("Form")
            Form.resize(685, 465)
            Form.setStyleSheet("background-color: rgb(213, 213, 213);")
            self.label = QtWidgets.QLabel(parent=Form)
            self.label.setGeometry(QtCore.QRect(130, 80, 501, 71))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(28)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.label.setFont(font)
            self.label.setObjectName("label")
            self.pushButton = QtWidgets.QPushButton(parent=Form)
            self.pushButton.setGeometry(QtCore.QRect(220, 340, 261, 51))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(12)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.pushButton.setFont(font)
            self.pushButton.setStyleSheet("background-color: rgb(189, 189, 189);")
            self.pushButton.setObjectName("pushButton")
            self.lineEdit = QtWidgets.QLineEdit(parent=Form)
            self.lineEdit.setGeometry(QtCore.QRect(90, 200, 501, 71))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(16)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.lineEdit.setFont(font)
            self.lineEdit.setObjectName("lineEdit")
    
            self.retranslateUi(Form)
            QtCore.QMetaObject.connectSlotsByName(Form)
    
        def retranslateUi(self, Form):
            _translate = QtCore.QCoreApplication.translate
            Form.setWindowTitle(_translate("Form", "Form"))
            self.label.setText(_translate("Form", "Введите номер стола"))
            self.pushButton.setText(_translate("Form", "Перейти к заказу"))
            
    
    #from заказ import Ui_Form as Ui_Form3
    class Ui_Form3(object):
        def setupUi(self, Form):
            Form.setObjectName("Form")
            Form.resize(1106, 884)
            Form.setStyleSheet("\n"
    "background-color: rgb(213, 213, 213);\n"
    "")
            self.label = QtWidgets.QLabel(parent=Form)
            self.label.setGeometry(QtCore.QRect(0, -10, 1111, 31))
            self.label.setObjectName("label")
            self.label_2 = QtWidgets.QLabel(parent=Form)
            self.label_2.setGeometry(QtCore.QRect(-20, 30, 1111, 31))
            self.label_2.setObjectName("label_2")
            self.label_3 = QtWidgets.QLabel(parent=Form)
            self.label_3.setGeometry(QtCore.QRect(10, 10, 131, 31))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(18)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.label_3.setFont(font)
            self.label_3.setObjectName("label_3")
            self.pushButton = QtWidgets.QPushButton(parent=Form)
            self.pushButton.setGeometry(QtCore.QRect(500, 110, 171, 101))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(18)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.pushButton.setFont(font)
            self.pushButton.setStyleSheet("background-color: rgb(193, 193, 193);")
            self.pushButton.setObjectName("pushButton")
            self.pushButton_2 = QtWidgets.QPushButton(parent=Form)
            self.pushButton_2.setGeometry(QtCore.QRect(690, 110, 171, 101))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(18)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.pushButton_2.setFont(font)
            self.pushButton_2.setStyleSheet("background-color: rgb(193, 193, 193);")
            self.pushButton_2.setObjectName("pushButton_2")
            self.pushButton_3 = QtWidgets.QPushButton(parent=Form)
            self.pushButton_3.setGeometry(QtCore.QRect(880, 110, 171, 101))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(18)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.pushButton_3.setFont(font)
            self.pushButton_3.setStyleSheet("background-color: rgb(193, 193, 193);")
            self.pushButton_3.setObjectName("pushButton_3")
            self.pushButton_4 = QtWidgets.QPushButton(parent=Form)
            self.pushButton_4.setGeometry(QtCore.QRect(500, 230, 171, 101))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(18)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.pushButton_4.setFont(font)
            self.pushButton_4.setStyleSheet("background-color: rgb(193, 193, 193);")
            self.pushButton_4.setObjectName("pushButton_4")
            self.pushButton_5 = QtWidgets.QPushButton(parent=Form)
            self.pushButton_5.setGeometry(QtCore.QRect(690, 230, 171, 101))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(18)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.pushButton_5.setFont(font)
            self.pushButton_5.setStyleSheet("background-color: rgb(193, 193, 193);")
            self.pushButton_5.setObjectName("pushButton_5")
            self.pushButton_6 = QtWidgets.QPushButton(parent=Form)
            self.pushButton_6.setGeometry(QtCore.QRect(880, 230, 171, 101))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(18)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.pushButton_6.setFont(font)
            self.pushButton_6.setStyleSheet("background-color: rgb(193, 193, 193);")
            self.pushButton_6.setObjectName("pushButton_6")
            self.line = QtWidgets.QFrame(parent=Form)
            self.line.setGeometry(QtCore.QRect(471, 100, 16, 771))
            self.line.setFrameShape(QtWidgets.QFrame.Shape.VLine)
            self.line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
            self.line.setObjectName("line")
            self.label_4 = QtWidgets.QLabel(parent=Form)
            self.label_4.setGeometry(QtCore.QRect(10, 110, 201, 31))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(16)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.label_4.setFont(font)
            self.label_4.setObjectName("label_4")
            self.line_2 = QtWidgets.QFrame(parent=Form)
            self.line_2.setGeometry(QtCore.QRect(0, 90, 1091, 16))
            self.line_2.setFrameShape(QtWidgets.QFrame.Shape.HLine)
            self.line_2.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
            self.line_2.setObjectName("line_2")
            self.label_5 = QtWidgets.QLabel(parent=Form)
            self.label_5.setGeometry(QtCore.QRect(10, 60, 71, 31))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(12)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.label_5.setFont(font)
            self.label_5.setObjectName("label_5")
            self.tableWidget = QtWidgets.QTableWidget(parent=Form)
            self.tableWidget.setGeometry(QtCore.QRect(10, 150, 451, 721))
            self.tableWidget.setObjectName("tableWidget")
            self.tableWidget.setColumnCount(0)
            self.tableWidget.setRowCount(0)
            self.label_6 = QtWidgets.QLabel(parent=Form)
            self.label_6.setGeometry(QtCore.QRect(170, 10, 131, 31))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(16)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.label_6.setFont(font)
            self.label_6.setStyleSheet("background-color: rgb(226, 226, 226);")
            self.label_6.setText("")
            self.label_6.setObjectName("label_6")
            self.label_7 = QtWidgets.QLabel(parent=Form)
            self.label_7.setGeometry(QtCore.QRect(100, 60, 571, 31))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(16)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.label_7.setFont(font)
            self.label_7.setStyleSheet("background-color: rgb(226, 226, 226);")
            self.label_7.setText("")
            self.label_7.setObjectName("label_7")
            self.label_8 = QtWidgets.QLabel(parent=Form)
            self.label_8.setGeometry(QtCore.QRect(230, 110, 131, 31))
            font = QtGui.QFont()
            font.setFamily("Palatino Linotype")
            font.setPointSize(14)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.label_8.setFont(font)
            self.label_8.setStyleSheet("background-color: rgb(226, 226, 226);")
            self.label_8.setText("")
            self.label_8.setObjectName("label_8")
            self.line.raise_()
            self.label_2.raise_()
            self.label.raise_()
            self.label_3.raise_()
            self.pushButton.raise_()
            self.pushButton_2.raise_()
            self.pushButton_3.raise_()
            self.pushButton_4.raise_()
            self.pushButton_5.raise_()
            self.pushButton_6.raise_()
            self.label_4.raise_()
            self.line_2.raise_()
            self.label_5.raise_()
            self.tableWidget.raise_()
            self.label_7.raise_()
            self.label_6.raise_()
            self.label_8.raise_()
    
            self.retranslateUi(Form)
            QtCore.QMetaObject.connectSlotsByName(Form)
    
        def retranslateUi(self, Form):
            _translate = QtCore.QCoreApplication.translate
            Form.setWindowTitle(_translate("Form", "Оформление заказа"))
            self.label.setText(_translate("Form", "------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"))
            self.label_2.setText(_translate("Form", "------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"))
            self.label_3.setText(_translate("Form", "Стол №"))
            self.pushButton.setText(_translate("Form", "завтрак"))
            self.pushButton_2.setText(_translate("Form", "холодное"))
            self.pushButton_3.setText(_translate("Form", "горячее"))
            self.pushButton_4.setText(_translate("Form", "суп"))
            self.pushButton_5.setText(_translate("Form", "выпечка"))
            self.pushButton_6.setText(_translate("Form", "десерт"))
            self.label_4.setText(_translate("Form", "Состав заказа:"))
            self.label_5.setText(_translate("Form", "кассир:"))
            
    
    #class Zakaz(QMainWindow):
    class Zakaz(QWidget):                                      # +++ QWidget
        def __init__(self, parent=None):                       # 2 +++ parent
            super(Zakaz, self).__init__()
            
            self.parent = parent                               # 3 +++
    
            self.ui = Ui_Form3()
            self.ui.setupUi(self)
    #        #self.sto = self.st #здесь в теории хочу записать данные из другого класса
            self.sto = self.parent.st                          # 4 +++
            print(f'self.sto ---> {self.parent.st}')
    
            self.ui.label_6.setText(self.sto)  # 5 <--- сюда писать self.sto
    
    
    #class Stol(QMainWindow):
    class Stol(QWidget):                                       # +++ QWidget
        def __init__(self):
            super().__init__()
    
            self.ui = Ui_Form2()
            self.ui.setupUi(self)
            self.stol = self.ui.lineEdit
            self.ui.pushButton.clicked.connect(self.btn)
    
    
        def btn(self):
            self.st = self.stol.text() #переформотировала введеное число в текст
            print(self.st)
            self.main_window = Zakaz(self)                     # 1 +++ self
            self.main_window.show()
            self.hide()
            
    
    if __name__ == "__main__":
        app = QApplication([])
        window = Stol()
        window.show()
        app.exec()
    

    在此输入图像描述

    在此输入图像描述


    有什么不清楚的地方就问。

    • 0

相关问题

  • 是否可以以某种方式自定义 QTabWidget?

  • telebot.anihelper.ApiException 错误

  • Python。检查一个数字是否是 3 的幂。输出 无

  • 解析多个响应

  • 交换两个数组的元素,以便它们的新内容也反转

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5