[PyQt] QAbstractItemModel.setData() and emit

Andreas Pakulat apaku at gmx.de
Thu Jul 19 23:27:14 BST 2007

On 19.07.07 13:53:30, Tom Brown wrote:
> I started out using the Qt models for four comboxes. This was during 
> development on my linux box. That worked very well and I was able to easily 
> subclass QSQLQueryModel. Then I went to test it out in Windows and it 
> wouldn't run because it needed PostgreSQL drivers. That means I'd have to 
> install PostgreSQL on all the target client machines in production. I thought 
> I could avoid that by creating my own model. Now it is looking like 
> installing PostgreSQL may be an easier solution.

You don't need a full PostgreSQL installation, all you need is the
client library which is normally available as dll. Also you always need
that client lib no matter how you do the db access (i.e. Qt, some python

> I guess I'm confused about how the model is supposed to work. insertRecord() 
> inserts a new record into the database, but not a new row into the 
> self.queryData that is used to populate the combobox. insertRows() does 
> insert a new (empty) row into self.queryData. Then setData() populates the 
> empty row. Well, that's what I think should happen.

I think you're confused about what your model actually should "model". I
thought it would show a part of your database and each time a new record
is inserted that should be reflected in the model. If thats the case
insertRecord should create a new row and use the begin/endInsertRows
calls. If not then  I don't understand why insertRecord is in that model
at all.


While you recently had your problems on the run, they've regrouped and
are making another attack.

More information about the PyQt mailing list