[PyQt] Problem with QValidator

Björn Häuser bjoernhaeuser at googlemail.com
Wed Jun 10 19:42:19 BST 2009


Phil Thompson schrieb:
> On Tue, 09 Jun 2009 20:30:27 +0200, "Björn Häuser"
> <bjoernhaeuser at googlemail.com> wrote:
>> Phil Thompson schrieb:
>>> On Sun, 07 Jun 2009 16:23:03 +0200, "Björn Häuser"
>>> <bjoernhaeuser at googlemail.com> wrote:
>>>> Hello List!
>>>>
>>>> I have a Problem with my own QValidator. Just tried to write one which 
>>>> checks the length of a input field.
>>>>
>>>> Traceback (most recent call last):
>>>>    File "window.py", line 97, in <module>
>>>>      window = Window(config)
>>>>    File "window.py", line 26, in __init__
>>>>      self.ui.username.setValidator(vsl)
>>>> RuntimeError: underlying C/C++ object has been deleted
>>>>
>>>>
>>>> This is the error i get when trying to use it.
>>>>
>>>>          vsl = validStringLength(2, 8, self)
>>>>          self.ui.username.setValidator(vsl)
>>>>
>>>> This the basic code for using the validator.
>>>>
>>>> http://pastie.org/503567 - this is the rest of this file.
>>>> http://pastie.org/503568 - this is the validator file.
>>>>
>>>> Any help appreciated (and any suggestions, especially regarding code 
>>>> quality).
>>> I'm guessing that you are not keeping a reference to your validator.
> I'll
>>> change things so that a reference is kept automatically.
>>>
>>> Phil
>> Thanks Phil for your answer.
>>
>> How do i keep such a reference? I also tried to use self.vsl, but 
>> getting the same error.
> 
> self.vsl should be fine. Like I said, I'm only guessing that's the problem.
> 
> Phil

Hello Phil!

http://pastie.org/507585 - this code gives me the same error.

Can you give me some working example for using QValidator?

Thanks in advance,
Björn



More information about the PyQt mailing list