0

我想在我的 QPlainTextEdit 中添加 required ,这样当有一个空白的 QPlainTextEdit 时,将提示用户有一个空白输入。

这是我的示例代码,我想在 QPlainTextEdit 中添加所需的内容。

self.plainTextEdit = QtGui.QPlainTextEdit(Form)
self.plainTextEdit.setGeometry(QtCore.QRect(110, 80, 251, 31))      
self.plainTextEdit.setObjectName(_fromUtf8("txtName")) 

谢谢你的回答!。

4

1 回答 1

0

你可以有一些这样的代码:

def on_submit(self, text): #set this to trigger once the user has submitted their text
    if text == "":
        print("You must enter some text") #or any other method of prompting the user
    else:
        self.text = text #or any other variable you want the text to be stored to

很不言自明。如果您愿意,我可以提供一个示例程序。

希望这可以帮助。

于 2018-12-11T20:02:53.930 回答