title: PyQt4 QDialog -- require field to not be blank
body: <p>OK, this is driving me nuts.  I'm sure it is trivial, but I've been looking for the answer for a while and don't see it.  I'm sure it will be a flat forehead.</p>
  
  <p>I'm designing a Qt4 dialog in Python. I generated the code via QDesigner, and have 4 inputs on the system:  </p>
  
  <ul>
  <li>QLineEdit (can't be blank)</li>
  <li>QPlainTextEdit</li>
  <li>QLineEdit  (can't be blank)</li>
  <li>QComboBox  (need to select one of the options)</li>
  </ul>
  
  <p>Question:  Is there a flag which makes a field "required"?  Forces it to be non-blank?</p>
  
  <p>I was trying to use a QRegExpValidator, but not sure this is right:</p>
  
  <pre><code>    regex = QRegExp(r"\\S+")        
      self.optionName.setValidator(QRegExpValidator(regex,self))
  </code></pre>
  
  <p>I know I'm missing something obvious (please, don't let it be a self.optionName.setRequired() function).  </p>
  
  <p><strong>Update</strong></p>
  
  <p>I've now added this class:</p>
  
  <pre><code>from PyQt4 import QtGui
  
  class ValidStringLength(QtGui.QValidator):
      def __init__(self, min, max, parent):
          QtGui.QValidator.__init__(self, parent)
  
          self.min = min
          self.max = max
  
      def validate(self, s, pos):
          if self.max &gt; -1 and len(s) &gt; self.max:
              return (QValidator.Invalid, pos)
  
          if self.min &gt; -1 and len(s) &lt; self.min:
              return (QValidator.Intermediate, pos)
  
          return (QValidator.Acceptable, pos)
  
      def fixup(self, s):
          pass
  </code></pre>
  
  <p>Call it like this:</p>
  
  <pre><code>    self.optionName.setValidator(ValidStringLength(2, 8, self.optionName))
      self.criteriaName.setValidator(ValidStringLength(2, 8, self.criteriaName))
  </code></pre>
  
  <p>and have a breakpoint set at the validate() function of the class, but that is never called.</p>
  
  <p>Am I missing something basic?</p>
  
  <p>TIA</p>
  
  <p>Mike</p>