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

Mark Summerfield list at qtrac.plus.com
Sun May 9 07:43:22 BST 2010


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


More information about the PyQt mailing list