[PyQt] best way to manage forms?

Linos info at linos.es
Thu Jan 29 11:27:52 GMT 2009


simozack escribió:
> 2009/1/27, Linos <info at linos.es>:
> 
>> For an example form that i would need to manage i have a customer table and
>> an address table (because for every customer they can have > 1 addresses) so
>> in the same form i would like to edit all the possible data of the customer.
> 
> It seems a work for two QSqlTableModel...
> 
>> I would like to do without using tables for the fields (well to select the
>> address to edit i can use a table but only to populate the data in the
>> correct widgets), QSqlTableModel or QSqlRelationalTableModel dont seems to
>> fit very well in this scenario, am i supposed to create two different
>> QSqlTableModel and other two different QDataWidgetMapper (one for every
>> table implicated)?, and if i want to select the customer searching for it
>> how could i do?, setting a filter in the two models? i am not interested in
>> next or previous buttons and qdatawidgetmapper seems to be all about them.
> 
> If you use the QTableView to view the data, you don't need
> QDataWidgetMapper. You can activate the edit triggers to directly
> modify the data.
> 
> How to do that is well explained in the PyQt Book by Mark Summerfield,
> who posts here sometimes, in particular in the chapter 15. You should
> download from the book site the source code of that chapter and look
> to the assetmanager example.

Yes i have read the book, anyway i will read other time the chapter 15 only in 
case i have missed anything important, but i prefer my users edit the 
information in external widgets, for example the address street it is too long 
to edit it clearly inside the table, i will use the table to select the 
information to populate the widgets. Any time ago the people had complaining 
about the bugs in qdatawidgetmapper, do it works reliable now? I have not used 
ever it.

>> It is this the best way to create database forms with qt? i have been
>> thinking about use SQLAlchemy to do this but i would like to go only with qt
>> if it is possible because i would like to left open the possibility of a c++
>> port of the application. Any better idea o suggestion? Thanks.
> 
> IMHO you don't need SQLAlchemy, you can do everything via the QtSql module.
> 
> HTH,
> Simone

Regards,
Miguel Angel.


More information about the PyQt mailing list