[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] auto-completing combo box with table view
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2007-11-28 12:02:21
Message-ID: 20071128120221.GA25092 () morpheus ! apaku ! dnsalias ! org
[Download RAW message or body]

On 28.11.07 22:16:09, Horst Herb wrote:
> On Wednesday 28 November 2007, Andreas Pakulat wrote:
> > That model provides data, no matter wether the index is valid or not or
> > the role matches Qt.DisplayRole. That means you break the contract
> > between model and view.
> 
> It is just a dummy to deliver some data to test the widget - should do that 
> trick

Not necessarily, especially the role-thing might confuse the view.

> > > class MyCompleter(QCompleter):
> > >     def __init__(self, parent=None):
> > >         super(MyCompleter, self).__init__(parent)
> > >         model = MyCompletionModel()
> >
> > Thats another bad idea, you don't keep a reference to the model so it
> > will disappear as soon as __init__ is done.
> 
> Really:
> model = MyCompletionModel()
> self.setModel(model)
>
> I would have thought that if I pass the model to the completer via setModel, 
> it keep the reference alive

AFAIK thats not possible, due to the interaction between C++ and Python
here, i.e. what is kept is the C++ part of your model, but the python
part goes into nirvana. (I hope Phil doesn't kill me for that
explanation). Check the PyQt examples, they do keep a reference to the
model too (simpledommodel.py for example)

Andreas

-- 
Lady Luck brings added income today.  Lady friend takes it away tonight.
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic