如果想在画图板上添加一个编辑框,直接new 一个lineEdit然后show出来就可以了.
setPlainText()
toPlainText()
setHtml()
toHtml()
clear()
'''
【简介】
PyQt5中 QTextEdit例子
'''
from PyQt5.QtWidgets import QApplication, QWidget, QTextEdit, QVBoxLayout, QPushButton
import sys
class TextEditDemo(QWidget):
def init (self, parent=None):
super(TextEditDemo, self). init (parent)
self.setWindowTitle("QTextEdit 例子")
self.resize(300, 270)
self.textEdit = QTextEdit()
self.btnPress1 = QPushButton("显示文本")
self.btnPress2 = QPushButton("显示HTML")
layout = QVBoxLayout()
layout.addWidget(self.textEdit)
layout.addWidget(self.btnPress1)
layout.addWidget(self.btnPress2)
self.setLayout(layout)
self.btnPress1.clicked.connect(self.btnPress1_Clicked)
self.btnPress2.clicked.connect(self.btnPress2_Clicked)
if name == " main ":
app = QApplication(sys.argv)
win = TextEditDemo()
win.show()
sys.exit(app.exec_())
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)