pyqt4 中怎么读取QlineEdit中的内容
我写了个GUI
其中有三个部件 QLineEdit,QPushButton,QTextEdit
主要的功能是 在QLineEdit中输入内容然后点QpushButto将内容显示于QTextEdit 中
我用QLineEdit.Text() 读取QLineEdit中的内容
怎么搞不定啊????
请大家随便说说
提醒我一下~!~!~!~
代码如下::::::::::::::::::::::
from PyQt4 import QtCore, QtGui
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.gridLayout = QtGui.QGridLayout(Form)
self.gridLayout.setObjectName("gridLayout")
self.lineEdit = QtGui.QLineEdit(Form)
self.lineEdit.setObjectName("lineEdit")
self.gridLayout.addWidget(self.lineEdit, 0, 0, 1, 1)
self.pushButton = QtGui.QPushButton(Form)
self.pushButton.setObjectName("pushButton")
self.gridLayout.addWidget(self.pushButton, 0, 1, 1, 1)
self.pushButton_2 = QtGui.QPushButton(Form)
self.pushButton_2.setObjectName("pushButton_2")
self.gridLayout.addWidget(self.pushButton_2, 0, 2, 1, 1)
self.textEdit = QtGui.QTextEdit(Form)
self.textEdit.setObjectName("textEdit")
self.gridLayout.addWidget(self.textEdit, 1, 0, 1, 3)
self.retranslateUi(Form)
QtCore.QObject.connect(self.pushButton_2, QtCore.SIGNAL("clicked()"), Form.close)
QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL("clicked()"), self.dialog)
QtCore.QMetaObject.connectSlotsByName(Form)
def dialog(self):
faile_dialog = self.lineEdit.Text()
self.textEdit.setText(faile_dialog)
def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setText(QtGui.QApplication.translate("Form", "Ok", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_2.setText(QtGui.QApplication.translate("Form", "Canel", None, QtGui.QApplication.UnicodeUTF8))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Form = QtGui.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
其中有三个部件 QLineEdit,QPushButton,QTextEdit
主要的功能是 在QLineEdit中输入内容然后点QpushButto将内容显示于QTextEdit 中
我用QLineEdit.Text() 读取QLineEdit中的内容
怎么搞不定啊????
请大家随便说说
提醒我一下~!~!~!~
代码如下::::::::::::::::::::::
from PyQt4 import QtCore, QtGui
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.gridLayout = QtGui.QGridLayout(Form)
self.gridLayout.setObjectName("gridLayout")
self.lineEdit = QtGui.QLineEdit(Form)
self.lineEdit.setObjectName("lineEdit")
self.gridLayout.addWidget(self.lineEdit, 0, 0, 1, 1)
self.pushButton = QtGui.QPushButton(Form)
self.pushButton.setObjectName("pushButton")
self.gridLayout.addWidget(self.pushButton, 0, 1, 1, 1)
self.pushButton_2 = QtGui.QPushButton(Form)
self.pushButton_2.setObjectName("pushButton_2")
self.gridLayout.addWidget(self.pushButton_2, 0, 2, 1, 1)
self.textEdit = QtGui.QTextEdit(Form)
self.textEdit.setObjectName("textEdit")
self.gridLayout.addWidget(self.textEdit, 1, 0, 1, 3)
self.retranslateUi(Form)
QtCore.QObject.connect(self.pushButton_2, QtCore.SIGNAL("clicked()"), Form.close)
QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL("clicked()"), self.dialog)
QtCore.QMetaObject.connectSlotsByName(Form)
def dialog(self):
faile_dialog = self.lineEdit.Text()
self.textEdit.setText(faile_dialog)
def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setText(QtGui.QApplication.translate("Form", "Ok", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_2.setText(QtGui.QApplication.translate("Form", "Canel", None, QtGui.QApplication.UnicodeUTF8))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Form = QtGui.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
...全文
相关推荐
python + QT4 上位机开发
PYQT4开发的串口调试软件,代码清晰适合Python刚入门者学习,比较实用的工具
PyQt5的各种示例代码
PyQt5的各种示例代码, This file is part of the examples of PyQt.
pyqt5 textEdit、lineEdit操作的示例代码
主要介绍了pyqt5 textEdit、lineEdit操作的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
PyQt5-SerialPort-Stable-master.zip
直接运行,亲测好用
pyqt弹出新对话框,以及关闭对话框获取数据的实例
今天小编就为大家分享一篇pyqt弹出新对话框,以及关闭对话框获取数据的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧


