[PyQt] Issue with QValidator
Phil Thompson
phil at riverbankcomputing.com
Thu Dec 22 17:27:16 GMT 2016
On 22 Dec 2016, at 5:18 pm, Thomas Daniel <tomek.daniel at gmail.com> wrote:
>
> Here is the simple test script:
>
> #!/usr/bin/env python3
>
> from PyQt5.QtWidgets import *
> from PyQt5.QtGui import *
> from PyQt5.QtCore import *
>
> import sys
>
> class Validator(QValidator):
> def __init__(self, parent = None):
> super().__init__(parent)
> def validate(self, name, pos):
> return QValidator.Acceptable
>
> class Widget(QDialog):
> def __init__(self, parent = None):
> super().__init__(parent)
> line_edit = QLineEdit(self)
> line_edit.setValidator(Validator())
>
> app = QApplication(sys.argv)
> widget = Widget()
> widget.show()
> app.exec_()
>
>
> Running the script results in
> TypeError: invalid result from Validator.validate()
>
> Testing with PyQt5.7 on ubuntu 16.04, installed with apt-get install
> python3-pyqt5.
>
> I can't figure out what I am doing wrong!
help(QValidator.validate)
Phil
More information about the PyQt
mailing list