pyqt按下参数输入按钮后,出现一个表格。

我在用pyqt实现按下参数输入按钮后,出现一个表格,然后在表格中输入数据。请问如何在叉掉表格弹出框后,再次点击按钮还显示之前输入的数据?如何用其中三个表格中的数据来算出第四个数?

import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
################################################
#######创建主窗口
################################################
class FirstMainWindow(QMainWindow):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.setWindowTitle('主界面')
        self.resize(1200, 700)

        ###### 创建界面 ######
        self.centralwidget = QWidget()
        self.setCentralWidget(self.centralwidget)
        self.Layout = QVBoxLayout(self.centralwidget)

        # 设置按钮
        self.pushButton1 = QPushButton(self)
        self.pushButton1.setText('软件使用指导')
        self.pushButton1.move(10, 10)
        self.pushButton2 = QPushButton(self)
        self.pushButton2.setText('参数输入')
        self.pushButton2.move(300, 10)
        self.pushButton3 = QPushButton(self)
        self.pushButton3.setText('参数评定')
        self.pushButton3.move(500, 10)
        self.pushButton4 = QPushButton(self)
        self.pushButton4.setText('保存')
        self.pushButton4.move(750, 10)
        self.pushButton5 = QPushButton(self)
        self.pushButton5.setText('调用')
        self.pushButton5.move(1000, 10)
        self.pushButton6 = QPushButton(self)
        self.pushButton6.setText('导入图片')
        self.pushButton6.move(10, 50)
        self.pushButton7 = QPushButton(self)
        self.pushButton7.setText('图像处理')
        self.pushButton7.move(10, 250)
        self.pushButton8 = QPushButton(self)
        self.pushButton8.setText('图像处理')
        self.pushButton8.move(10, 450)






        ###### 三个按钮事件 ######
        self.pushButton1.clicked.connect(self.on_pushButton1_clicked)
        self.pushButton2.clicked.connect(self.on_pushButton2_clicked)





    # 按钮一:打开主界面
    def on_pushButton1_clicked(self):
        text = self.sender().text()
        if text == '软件使用指导':
            QMessageBox.about(self, '使用指导', '按下参数输入可以输入原始参数,便于对比数据;按下保存按钮可以保存分析后的数据,按下调用可以调出之前')


    # 按钮二:打开对话框
    def on_pushButton2_clicked(self):
        the_dialog = TestdemoDialog()
        if the_dialog.exec_() == QDialog.Accepted:
            pass
    # 按钮二:打开对话框
    def on_pushButton3_clicked(self):
        the_dialog = QFileDialogDemo()
        if the_dialog.exec_() == QWidget.Accepted:
            pass








################################################
#######b表格框
################################################
class TestdemoDialog(QDialog):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        hhbox = QHBoxLayout()  # 横向布局

        tableWidget = QTableWidget()  # 创建一个表格

        tableWidget.setRowCount(1)
        tableWidget.setColumnCount(4)  # 1行5列

        tableWidget.setHorizontalHeaderLabels(['▲d2', '▲d', '▲α/2', '▲P'])
        tableWidget.setVerticalHeaderLabels(['原始参数'])
        # 表头

        hhbox.addWidget(tableWidget)  # 把表格加入布局

        self.setLayout(hhbox)  # 创建布局

        self.setWindowTitle("原始参数")
        self.resize(725, 90)
        self.show()
################################################
#######图片框
################################################
class QFileDialogDemo(QWidget):
    def __init__(self):
        super(QFileDialogDemo,self).__init__()
        self.initUI()

    def initUI(self):
        layout = QVBoxLayout()
        self.button1 = QPushButton('加载图片')
        self.button1.clicked.connect(self.loadImage)
        layout.addWidget(self.button1)

        self.imageLabel = QLabel()
        layout.addWidget(self.imageLabel)



        self.setLayout(layout)
        self.setWindowTitle('文件对话框演示 ')

    def loadImage(self):
        fname,_ = QFileDialog.getOpenFileName(self,'打开文件','.','图像文件(*.jpg *.png)')
        self.imageLabel.setPixmap(QPixmap(fname))

    def loadText(self):
        dialog = QFileDialog()
        dialog.setFileMode(QFileDialog.AnyFile)
        dialog.setFilter(QDir.Files)

        if dialog.exec():
            filenames = dialog.selectedFiles()
            f = open(filenames[0],encoding='utf-8',mode='r')
            with f:
                data = f.read()
                self.contents.setText(data)



################################################
#######程序入门
################################################
if __name__ == "__main__":
    app = QApplication(sys.argv)
    the_mainwindow = FirstMainWindow()
    the_mainwindow.show()
    sys.exit(app.exec_())

 

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 以帮助更多的人 ^-^