1

I want to add required in my QPlainTextEdit so that when there is a blank QPlainTextEdit, the user will then be prompted that there is a blank input.

This is my sample code and I want to add required in that QPlainTextEdit.

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

Thanks for some answer!.

  • 1
    Do you want the QPlainTextEdit to have a placeholder that indicates that it is necessary that the QPlainTextEdit should not be empty with any message? – eyllanesc Dec 11 '18 at 19:29
  • I want that if the user will submit it, if there is a blank QPlainTextEdit, the user will prompt. – Nikko James Santillan Dec 11 '18 at 19:44
  • 1
    Hello Nikko and welcome to the Stack-Overflow community. Please make sure that you are 'crystal-clear' as to what your question is, so that people reading your post can easily understand it and help you! – Soutzikevich Dec 11 '18 at 19:45
  • 1
    @NikkoJamesSantillan You have confused me more, explain yourself better. Please read [ask] and review the [tour] – eyllanesc Dec 11 '18 at 19:49

1 Answers1

1

You can have some code like this:

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

Pretty self-explanatory. I can provide an example program if you wish.

Hope this helps.

Jachdich
  • 782
  • 8
  • 23