如何从PyQt制作响应对话框,以便在调整大小时适合内容

时间:2019-07-11 02:58:56

标签: python python-3.x pyqt pyqt5

我有一个简单的对话框,其中包含一个“行编辑”和一个“按钮”小部件。运行应用程序并调整对话框大小后 这些小部件(LineEdit和PushButton)的大小不适合对话框。如何在调整大小的同时使这些项目响应 对话框。

class Ui_ZValue(object):
    def setupUi(self, ZValue):
        ZValue.setObjectName("ZValue")
        ZValue.resize(400, 300)
        ZValue.setModal(False)
        self.lineEdit = QtWidgets.QLineEdit(ZValue)
        self.lineEdit.setGeometry(QtCore.QRect(130, 70, 131, 41))
        self.lineEdit.setObjectName("lineEdit")
        self.pushButton = QtWidgets.QPushButton(ZValue)
        self.pushButton.setGeometry(QtCore.QRect(130, 150, 131, 41))
        self.pushButton.setObjectName("pushButton")

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

    def retranslateUi(self, ZValue):
        _translate = QtCore.QCoreApplication.translate
        ZValue.setWindowTitle(_translate("ZValue", "Copy Z Cordinate"))
        self.pushButton.setText(_translate("ZValue", "Cofirm"))


import sys
from PyQt5.QtWidgets import QDialog,QApplication
from  makebeautiful import *
class MyForm(QDialog):
    def __init__(self):
        super().__init__()
        self.ui=Ui_ZValue()
        self.ui.setupUi(self)
        self.ui.pushButton.clicked.connect(self.dispmessage)
        self.show()
    def dispmessage(self):
        self.ui.lineEdit.setText("clicked")
if __name__=="__main__":
    app=QApplication(sys.argv)

    w=MyForm()
    w.show()
    sys.exit(app.exec_())

0 个答案:

没有答案