[PyQt] Master-detail relationship with plain QTableView tables (no SQL database)

Vadym Honcharuk intereco at gmail.com
Thu May 20 05:46:58 BST 2010


2010/5/9 Mark Summerfield <list at qtrac.plus.com>:
> On 2010-05-08, Vadym Honcharuk wrote:
>> Hi to All,
>>
>> I need three tables with master-detail relationship one to other. I
>> made QTableView Model from Mark book and three vertical frame on one
>> page for it. How  possible connect these tables with master-detail
>> relationship? Examples are really welcome if possible...
>
> Hi Vadym,
>
> My book shows how to do master-detail in the context of a SQL database
> (e.g. pp. 463), but the same technique can be applied to any pair of
> table models.
>
> One approach is to connect the master table's selectionModel()'s
> currentRowChanged(QModelIndex,QModelIndex) signal to a custom slot.
> Then, in the custom slot you handle the populating of the detail table,
> for example, by filtering (which you can do with a sort/filter proxy
> model).
>
>
> --
> Mark Summerfield, Qtrac Ltd, www.qtrac.eu
>    C++, Python, Qt, PyQt - training and consultancy
>        "C++ GUI Programming with Qt 4" - ISBN 0132354160
>

Thank you, Mark!

One more question in this issue is how to save data from these three
tables with different models in one file by QDataStream module. The
point of problem in that save method calling  from their models itself
and if I have  three models  - every will try open same file and save
data in series? But seems this is not too correct desicion...

With best rgards,
-vadym


More information about the PyQt mailing list