PyQt5-使用Line Edit从编辑窗口更新标签

时间:2019-03-10 17:47:48

标签: python pyqt5

我在创建程序时遇到了麻烦,我有两个窗口,其中主窗口可以看到所有数据,另一个是编辑窗口,在该窗口中可以使用编辑中的行编辑从主窗口中编辑或更新标签窗口

我想将更改从编辑窗口中的行编辑传递到主窗口中的标签

这是从Qt Designer派生的代码主窗口:

from PyQt5 import QtCore, QtGui, QtWidgets
from FinalEditForm import Ui_editWindow

class Ui_MainWindow(object):
def openWindow(self):
    self.window = QtWidgets.QMainWindow()
    self.ui = Ui_editWindow()
    self.ui.setupUi(self.window)
    self.window.show()
def setupUi(self, MainWindow):
    MainWindow.setObjectName("MainWindow")
    MainWindow.resize(634, 578)
    self.centralwidget = QtWidgets.QWidget(MainWindow)
    self.centralwidget.setObjectName("centralwidget")
    self.gridLayout_3 = QtWidgets.QGridLayout(self.centralwidget)
    self.gridLayout_3.setContentsMargins(10, 10, 10, 10)
    self.gridLayout_3.setObjectName("gridLayout_3")
    self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
    sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
    sizePolicy.setHorizontalStretch(0)
    sizePolicy.setVerticalStretch(0)
    sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth())
    self.tabWidget.setSizePolicy(sizePolicy)
    self.tabWidget.setObjectName("tabWidget")
    self.widget = QtWidgets.QWidget()
    self.widget.setObjectName("widget")
    self.gridLayout = QtWidgets.QGridLayout(self.widget)
    self.gridLayout.setContentsMargins(0, 0, 0, 0)
    self.gridLayout.setObjectName("gridLayout")
    self.scrollArea = QtWidgets.QScrollArea(self.widget)
    self.scrollArea.setWidgetResizable(True)
    self.scrollArea.setObjectName("scrollArea")
    self.scrollAreaWidgetContents = QtWidgets.QWidget()
    self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 588, 492))
    self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
    self.label = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label.setGeometry(QtCore.QRect(38, 20, 81, 21))
    font = QtGui.QFont()
    font.setPointSize(10)
    font.setBold(True)
    font.setWeight(75)
    self.label.setFont(font)
    self.label.setObjectName("label")
    self.label_2 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_2.setGeometry(QtCore.QRect(160, 20, 121, 21))
    font = QtGui.QFont()
    font.setPointSize(10)
    font.setBold(True)
    font.setWeight(75)
    self.label_2.setFont(font)
    self.label_2.setObjectName("label_2")
    self.label_3 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_3.setGeometry(QtCore.QRect(317, 20, 61, 21))
    font = QtGui.QFont()
    font.setPointSize(10)
    font.setBold(True)
    font.setWeight(75)
    self.label_3.setFont(font)
    self.label_3.setObjectName("label_3")
    self.label_4 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_4.setGeometry(QtCore.QRect(400, 20, 141, 21))
    font = QtGui.QFont()
    font.setPointSize(10)
    font.setBold(True)
    font.setWeight(75)
    self.label_4.setFont(font)
    self.label_4.setObjectName("label_4")
    self.label_5 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_5.setGeometry(QtCore.QRect(40, 50, 47, 13))
    self.label_5.setObjectName("label_5")
    self.label_6 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_6.setGeometry(QtCore.QRect(180, 50, 61, 13))
    self.label_6.setObjectName("label_6")
    self.label_7 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_7.setGeometry(QtCore.QRect(320, 49, 61, 16))
    self.label_7.setObjectName("label_7")
    self.label_8 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_8.setGeometry(QtCore.QRect(440, 49, 61, 16))
    self.label_8.setObjectName("label_8")
    self.label_9 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_9.setGeometry(QtCore.QRect(40, 70, 47, 13))
    self.label_9.setObjectName("label_9")
    self.label_10 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_10.setGeometry(QtCore.QRect(180, 70, 58, 13))
    self.label_10.setObjectName("label_10")
    self.label_11 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_11.setGeometry(QtCore.QRect(319, 68, 71, 16))
    self.label_11.setObjectName("label_11")
    self.label_12 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_12.setGeometry(QtCore.QRect(440, 69, 61, 16))
    self.label_12.setObjectName("label_12")
    self.label_13 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_13.setGeometry(QtCore.QRect(40, 90, 61, 16))
    self.label_13.setObjectName("label_13")
    self.label_14 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_14.setGeometry(QtCore.QRect(180, 90, 59, 13))
    self.label_14.setObjectName("label_14")
    self.label_15 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_15.setGeometry(QtCore.QRect(319, 88, 61, 16))
    self.label_15.setObjectName("label_15")
    self.label_16 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_16.setGeometry(QtCore.QRect(440, 89, 61, 16))
    self.label_16.setObjectName("label_16")
    self.label_17 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_17.setGeometry(QtCore.QRect(40, 110, 61, 16))
    self.label_17.setObjectName("label_17")
    self.label_18 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_18.setGeometry(QtCore.QRect(180, 110, 59, 13))
    self.label_18.setObjectName("label_18")
    self.label_19 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_19.setGeometry(QtCore.QRect(318, 109, 61, 16))
    self.label_19.setObjectName("label_19")
    self.label_20 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_20.setGeometry(QtCore.QRect(440, 109, 61, 16))
    self.label_20.setObjectName("label_20")
    self.pushButton = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
    self.pushButton.setGeometry(QtCore.QRect(490, 440, 75, 23))
    self.pushButton.setObjectName("pushButton")

    self.pushButton.clicked.connect(self.openWindow)

    self.label_21 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_21.setGeometry(QtCore.QRect(40, 130, 101, 16))
    self.label_21.setObjectName("label_21")
    self.label_22 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_22.setGeometry(QtCore.QRect(179, 130, 47, 13))
    self.label_22.setObjectName("label_22")
    self.label_23 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_23.setGeometry(QtCore.QRect(320, 129, 51, 16))
    self.label_23.setObjectName("label_23")
    self.label_24 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_24.setGeometry(QtCore.QRect(441, 130, 47, 13))
    self.label_24.setObjectName("label_24")
    self.label_25 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_25.setGeometry(QtCore.QRect(40, 150, 71, 16))
    self.label_25.setObjectName("label_25")
    self.label_26 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_26.setGeometry(QtCore.QRect(180, 150, 47, 13))
    self.label_26.setObjectName("label_26")
    self.label_27 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_27.setGeometry(QtCore.QRect(320, 150, 47, 13))
    self.label_27.setObjectName("label_27")
    self.label_28 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
    self.label_28.setGeometry(QtCore.QRect(440, 150, 47, 13))
    self.label_28.setObjectName("label_28")
    self.label.raise_()
    self.label_2.raise_()
    self.label_3.raise_()
    self.label_4.raise_()
    self.label_5.raise_()
    self.label_6.raise_()
    self.label_7.raise_()
    self.label_8.raise_()
    self.label_9.raise_()
    self.label_10.raise_()
    self.label_11.raise_()
    self.label_12.raise_()
    self.label_13.raise_()
    self.label_14.raise_()
    self.label_15.raise_()
    self.label_16.raise_()
    self.label_17.raise_()
    self.label_18.raise_()
    self.label_19.raise_()
    self.label_20.raise_()
    self.label_21.raise_()
    self.label_22.raise_()
    self.label_23.raise_()
    self.label_24.raise_()
    self.label_25.raise_()
    self.label_26.raise_()
    self.label_27.raise_()
    self.label_28.raise_()
    self.pushButton.raise_()
    self.scrollArea.setWidget(self.scrollAreaWidgetContents)
    self.gridLayout.addWidget(self.scrollArea, 0, 1, 1, 1)
    self.tabWidget.addTab(self.widget, "")
    self.tab_2 = QtWidgets.QWidget()
    self.tab_2.setObjectName("tab_2")
    self.checkBox = QtWidgets.QCheckBox(self.tab_2)
    self.checkBox.setGeometry(QtCore.QRect(20, 40, 70, 17))
    self.checkBox.setObjectName("checkBox")
    self.label_29 = QtWidgets.QLabel(self.tab_2)
    self.label_29.setGeometry(QtCore.QRect(30, 10, 81, 16))
    font = QtGui.QFont()
    font.setPointSize(10)
    font.setBold(True)
    font.setWeight(75)
    self.label_29.setFont(font)
    self.label_29.setObjectName("label_29")
    self.checkBox_2 = QtWidgets.QCheckBox(self.tab_2)
    self.checkBox_2.setGeometry(QtCore.QRect(20, 60, 70, 17))
    self.checkBox_2.setObjectName("checkBox_2")
    self.checkBox_3 = QtWidgets.QCheckBox(self.tab_2)
    self.checkBox_3.setGeometry(QtCore.QRect(20, 80, 76, 17))
    self.checkBox_3.setObjectName("checkBox_3")
    self.checkBox_4 = QtWidgets.QCheckBox(self.tab_2)
    self.checkBox_4.setGeometry(QtCore.QRect(20, 100, 78, 17))
    self.checkBox_4.setObjectName("checkBox_4")
    self.checkBox_5 = QtWidgets.QCheckBox(self.tab_2)
    self.checkBox_5.setGeometry(QtCore.QRect(20, 120, 117, 17))
    self.checkBox_5.setObjectName("checkBox_5")
    self.checkBox_6 = QtWidgets.QCheckBox(self.tab_2)
    self.checkBox_6.setGeometry(QtCore.QRect(20, 140, 85, 17))
    self.checkBox_6.setObjectName("checkBox_6")
    self.label_30 = QtWidgets.QLabel(self.tab_2)
    self.label_30.setGeometry(QtCore.QRect(180, 10, 45, 13))
    font = QtGui.QFont()
    font.setPointSize(10)
    font.setBold(True)
    font.setWeight(75)
    self.label_30.setFont(font)
    self.label_30.setObjectName("label_30")
    self.label_31 = QtWidgets.QLabel(self.tab_2)
    self.label_31.setGeometry(QtCore.QRect(270, 6, 62, 19))
    font = QtGui.QFont()
    font.setPointSize(10)
    font.setBold(True)
    font.setWeight(75)
    self.label_31.setFont(font)
    self.label_31.setObjectName("label_31")
    self.label_32 = QtWidgets.QLabel(self.tab_2)
    self.label_32.setGeometry(QtCore.QRect(180, 40, 65, 13))
    self.label_32.setObjectName("label_32")
    self.label_33 = QtWidgets.QLabel(self.tab_2)
    self.label_33.setGeometry(QtCore.QRect(180, 60, 63, 13))
    self.label_33.setObjectName("label_33")
    self.label_34 = QtWidgets.QLabel(self.tab_2)
    self.label_34.setGeometry(QtCore.QRect(180, 80, 61, 13))
    self.label_34.setObjectName("label_34")
    self.label_35 = QtWidgets.QLabel(self.tab_2)
    self.label_35.setGeometry(QtCore.QRect(180, 100, 63, 13))
    self.label_35.setObjectName("label_35")
    self.label_36 = QtWidgets.QLabel(self.tab_2)
    self.label_36.setGeometry(QtCore.QRect(180, 120, 47, 13))
    self.label_36.setObjectName("label_36")
    self.label_37 = QtWidgets.QLabel(self.tab_2)
    self.label_37.setGeometry(QtCore.QRect(180, 140, 47, 13))
    self.label_37.setObjectName("label_37")
    self.lineEdit = QtWidgets.QLineEdit(self.tab_2)
    self.lineEdit.setGeometry(QtCore.QRect(260, 35, 91, 20))
    self.lineEdit.setObjectName("lineEdit")
    self.lineEdit_2 = QtWidgets.QLineEdit(self.tab_2)
    self.lineEdit_2.setGeometry(QtCore.QRect(260, 57, 91, 20))
    self.lineEdit_2.setObjectName("lineEdit_2")
    self.lineEdit_3 = QtWidgets.QLineEdit(self.tab_2)
    self.lineEdit_3.setGeometry(QtCore.QRect(260, 78, 91, 20))
    self.lineEdit_3.setObjectName("lineEdit_3")
    self.lineEdit_4 = QtWidgets.QLineEdit(self.tab_2)
    self.lineEdit_4.setGeometry(QtCore.QRect(260, 99, 91, 20))
    self.lineEdit_4.setObjectName("lineEdit_4")
    self.lineEdit_5 = QtWidgets.QLineEdit(self.tab_2)
    self.lineEdit_5.setGeometry(QtCore.QRect(260, 120, 91, 20))
    self.lineEdit_5.setObjectName("lineEdit_5")
    self.lineEdit_6 = QtWidgets.QLineEdit(self.tab_2)
    self.lineEdit_6.setGeometry(QtCore.QRect(260, 141, 91, 20))
    self.lineEdit_6.setObjectName("lineEdit_6")
    self.pushButton_2 = QtWidgets.QPushButton(self.tab_2)
    self.pushButton_2.setGeometry(QtCore.QRect(350, 470, 70, 23))
    self.pushButton_2.setObjectName("pushButton_2")
    self.pushButton_3 = QtWidgets.QPushButton(self.tab_2)
    self.pushButton_3.setGeometry(QtCore.QRect(425, 470, 70, 23))
    self.pushButton_3.setObjectName("pushButton_3")
    self.label_38 = QtWidgets.QLabel(self.tab_2)
    self.label_38.setGeometry(QtCore.QRect(520, 471, 16, 16))
    self.label_38.setObjectName("label_38")
    self.label_39 = QtWidgets.QLabel(self.tab_2)
    self.label_39.setGeometry(QtCore.QRect(420, 10, 117, 19))
    font = QtGui.QFont()
    font.setPointSize(10)
    font.setBold(True)
    font.setWeight(75)
    self.label_39.setFont(font)
    self.label_39.setObjectName("label_39")
    self.label_40 = QtWidgets.QLabel(self.tab_2)
    self.label_40.setGeometry(QtCore.QRect(450, 38, 66, 13))
    self.label_40.setObjectName("label_40")
    self.label_41 = QtWidgets.QLabel(self.tab_2)
    self.label_41.setGeometry(QtCore.QRect(450, 60, 66, 13))
    self.label_41.setObjectName("label_41")
    self.label_42 = QtWidgets.QLabel(self.tab_2)
    self.label_42.setGeometry(QtCore.QRect(450, 81, 57, 13))
    self.label_42.setObjectName("label_42")
    self.label_43 = QtWidgets.QLabel(self.tab_2)
    self.label_43.setGeometry(QtCore.QRect(450, 102, 55, 13))
    self.label_43.setObjectName("label_43")
    self.label_44 = QtWidgets.QLabel(self.tab_2)
    self.label_44.setGeometry(QtCore.QRect(450, 124, 47, 15))
    self.label_44.setObjectName("label_44")
    self.label_45 = QtWidgets.QLabel(self.tab_2)
    self.label_45.setGeometry(QtCore.QRect(450, 145, 47, 13))
    self.label_45.setObjectName("label_45")
    self.tabWidget.addTab(self.tab_2, "")
    self.gridLayout_3.addWidget(self.tabWidget, 0, 0, 1, 1)
    MainWindow.setCentralWidget(self.centralwidget)
    self.statusbar = QtWidgets.QStatusBar(MainWindow)
    self.statusbar.setObjectName("statusbar")
    MainWindow.setStatusBar(self.statusbar)

    self.retranslateUi(MainWindow)
    self.tabWidget.setCurrentIndex(0)
    self.pushButton_2.clicked.connect(self.lineEdit.clear)
    QtCore.QMetaObject.connectSlotsByName(MainWindow)

def retranslateUi(self, MainWindow):
    _translate = QtCore.QCoreApplication.translate
    MainWindow.setWindowTitle(_translate("MainWindow", "Automated System Inventory"))
    self.label.setText(_translate("MainWindow", "Item Name"))
    self.label_2.setText(_translate("MainWindow", "Number of Stocks"))
    self.label_3.setText(_translate("MainWindow", "mSRP"))
    self.label_4.setText(_translate("MainWindow", "Sari-Sari Store Price"))
    self.label_5.setText(_translate("MainWindow", "RC Small"))
    self.label_6.setText(_translate("MainWindow", "120 (bottles)"))
    self.label_7.setText(_translate("MainWindow", "8.00/bottle"))
    self.label_8.setText(_translate("MainWindow", "10.00/bottle"))
    self.label_9.setText(_translate("MainWindow", "RC Big"))
    self.label_10.setText(_translate("MainWindow", "48 (bottles)"))
    self.label_11.setText(_translate("MainWindow", "21.00/bottle"))
    self.label_12.setText(_translate("MainWindow", "24.00/bottle"))
    self.label_13.setText(_translate("MainWindow", "Coke (Litro)"))
    self.label_14.setText(_translate("MainWindow", "48 (bottles)"))
    self.label_15.setText(_translate("MainWindow", "22.00/bottle"))
    self.label_16.setText(_translate("MainWindow", "26.00/bottle"))
    self.label_17.setText(_translate("MainWindow", "C2 (230 mL)"))
    self.label_18.setText(_translate("MainWindow", "48 (bottles)"))
    self.label_19.setText(_translate("MainWindow", "10.00/bottle"))
    self.label_20.setText(_translate("MainWindow", "12.00/bottle"))
    self.pushButton.setText(_translate("MainWindow", "Edit"))
    self.label_21.setText(_translate("MainWindow", "555 Tuna(Afritada)"))
    self.label_22.setText(_translate("MainWindow", "10 (cans)"))
    self.label_23.setText(_translate("MainWindow", "18.00/pc"))
    self.label_24.setText(_translate("MainWindow", "22.00/pc"))
    self.label_25.setText(_translate("MainWindow", "Cup Noodles"))
    self.label_26.setText(_translate("MainWindow", "10 (pcs)"))
    self.label_27.setText(_translate("MainWindow", "18.00/pc"))
    self.label_28.setText(_translate("MainWindow", "24.00/pc"))
    self.tabWidget.setTabText(self.tabWidget.indexOf(self.widget), _translate("MainWindow", "Stocks and Price"))
    self.checkBox.setText(_translate("MainWindow", "RC Small"))
    self.label_29.setText(_translate("MainWindow", "Item Name"))
    self.checkBox_2.setText(_translate("MainWindow", "RC Big"))
    self.checkBox_3.setText(_translate("MainWindow", "Coke (Litro)"))
    self.checkBox_4.setText(_translate("MainWindow", "C2 (230 mL)"))
    self.checkBox_5.setText(_translate("MainWindow", "555 Tuna (Afritada)"))
    self.checkBox_6.setText(_translate("MainWindow", "Cup Noodles"))
    self.label_30.setText(_translate("MainWindow", "Price"))
    self.label_31.setText(_translate("MainWindow", "Quantity"))
    self.label_32.setText(_translate("MainWindow", "10.00"))
    self.label_33.setText(_translate("MainWindow", "24.00"))
    self.label_34.setText(_translate("MainWindow", "26.00"))
    self.label_35.setText(_translate("MainWindow", "12.00"))
    self.label_36.setText(_translate("MainWindow", "22.00"))
    self.label_37.setText(_translate("MainWindow", "24.00"))
    self.pushButton_2.setText(_translate("MainWindow", "Reset"))
    self.pushButton_3.setText(_translate("MainWindow", "Total"))
    self.label_38.setText(_translate("MainWindow", "0"))
    self.label_39.setText(_translate("MainWindow", "Remaining Stocks"))
    self.label_40.setText(_translate("MainWindow", "120 (bottles)"))
    self.label_41.setText(_translate("MainWindow", "48(bottles)"))
    self.label_42.setText(_translate("MainWindow", "48(bottles)"))
    self.label_43.setText(_translate("MainWindow", "48(bottles)"))
    self.label_44.setText(_translate("MainWindow", "10 (pc)"))
    self.label_45.setText(_translate("MainWindow", "10 (pc)"))
    self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("MainWindow", "Sales"))

if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) MainWindow = QtWidgets.QMainWindow() ui = Ui_MainWindow() ui.setupUi(MainWindow) MainWindow.show() sys.exit(app.exec_())

这是来自Qt Designer的编辑窗口的代码:

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_editWindow(object):
def setupUi(self, editWindow):
    editWindow.setObjectName("editWindow")
    editWindow.setEnabled(True)
    editWindow.resize(627, 319)
    editWindow.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
    self.centralwidget = QtWidgets.QWidget(editWindow)
    self.centralwidget.setObjectName("centralwidget")
    self.label = QtWidgets.QLabel(self.centralwidget)
    self.label.setGeometry(QtCore.QRect(300, 20, 71, 31))
    font = QtGui.QFont()
    font.setPointSize(10)
    font.setBold(True)
    font.setWeight(75)
    self.label.setFont(font)
    self.label.setObjectName("label")
    self.label_2 = QtWidgets.QLabel(self.centralwidget)
    self.label_2.setGeometry(QtCore.QRect(10, 63, 47, 13))
    self.label_2.setText("")
    self.label_2.setObjectName("label_2")
    self.splitter_2 = QtWidgets.QSplitter(self.centralwidget)
    self.splitter_2.setGeometry(QtCore.QRect(70, 60, 532, 20))
    self.splitter_2.setOrientation(QtCore.Qt.Horizontal)
    self.splitter_2.setObjectName("splitter_2")
    self.lineEdit = QtWidgets.QLineEdit(self.splitter_2)
    sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
    sizePolicy.setHorizontalStretch(0)
    sizePolicy.setVerticalStretch(0)
    sizePolicy.setHeightForWidth(self.lineEdit.sizePolicy().hasHeightForWidth())
    self.lineEdit.setSizePolicy(sizePolicy)
    self.lineEdit.setObjectName("lineEdit")
    self.lineEdit_2 = QtWidgets.QLineEdit(self.splitter_2)
    sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
    sizePolicy.setHorizontalStretch(0)
    sizePolicy.setVerticalStretch(0)
    sizePolicy.setHeightForWidth(self.lineEdit_2.sizePolicy().hasHeightForWidth())
    self.lineEdit_2.setSizePolicy(sizePolicy)
    self.lineEdit_2.setObjectName("lineEdit_2")
    self.lineEdit_3 = QtWidgets.QLineEdit(self.splitter_2)
    sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
    sizePolicy.setHorizontalStretch(0)
    sizePolicy.setVerticalStretch(0)
    sizePolicy.setHeightForWidth(self.lineEdit_3.sizePolicy().hasHeightForWidth())
    self.lineEdit_3.setSizePolicy(sizePolicy)
    self.lineEdit_3.setObjectName("lineEdit_3")
    self.lineEdit_4 = QtWidgets.QLineEdit(self.splitter_2)
    sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
    sizePolicy.setHorizontalStretch(0)
    sizePolicy.setVerticalStretch(0)
    sizePolicy.setHeightForWidth(self.lineEdit_4.sizePolicy().hasHeightForWidth())
    self.lineEdit_4.setSizePolicy(sizePolicy)
    self.lineEdit_4.setStyleSheet("")
    self.lineEdit_4.setObjectName("lineEdit_4")
    self.splitter = QtWidgets.QSplitter(self.centralwidget)
    self.splitter.setGeometry(QtCore.QRect(360, 270, 225, 23))
    self.splitter.setOrientation(QtCore.Qt.Horizontal)
    self.splitter.setObjectName("splitter")
    self.pushButton_3 = QtWidgets.QPushButton(self.splitter)
    self.pushButton_3.setObjectName("pushButton_3")
    self.pushButton_2 = QtWidgets.QPushButton(self.splitter)
    self.pushButton_2.setObjectName("pushButton_2")
    self.pushButton = QtWidgets.QPushButton(self.splitter)
    self.pushButton.setObjectName("pushButton")
    editWindow.setCentralWidget(self.centralwidget)
    self.statusbar = QtWidgets.QStatusBar(editWindow)
    self.statusbar.setObjectName("statusbar")
    editWindow.setStatusBar(self.statusbar)

    self.retranslateUi(editWindow)
    self.pushButton.clicked.connect(self.label_2.clear)
    self.pushButton.clicked.connect(self.lineEdit.clear)
    self.pushButton.clicked.connect(self.lineEdit_2.clear)
    self.pushButton.clicked.connect(self.lineEdit_3.clear)
    self.pushButton.clicked.connect(self.lineEdit_4.clear)
    QtCore.QMetaObject.connectSlotsByName(editWindow)

def retranslateUi(self, editWindow):
    _translate = QtCore.QCoreApplication.translate
    editWindow.setWindowTitle(_translate("editWindow", "MainWindow"))
    self.label.setText(_translate("editWindow", "EDIT FORM"))
    self.lineEdit.setPlaceholderText(_translate("editWindow", "Item Name"))
    self.lineEdit_2.setPlaceholderText(_translate("editWindow", "Number of Stocks"))
    self.lineEdit_3.setPlaceholderText(_translate("editWindow", "mSRP"))
    self.lineEdit_4.setPlaceholderText(_translate("editWindow", "Sari-Sari Store Price"))
    self.pushButton_3.setText(_translate("editWindow", "Add Item"))
    self.pushButton_2.setText(_translate("editWindow", "Update"))
    self.pushButton.setText(_translate("editWindow", "Clear"))

if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) editWindow = QtWidgets.QMainWindow() ui = Ui_editWindow() ui.setupUi(editWindow) editWindow.show() sys.exit(app.exec_())

1 个答案:

答案 0 :(得分:0)

尝试一下:

unsafe

enter image description here