Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

Populate QTreeView from database tables

$
0
0
Hi, I am relatively new to Qt (I use PyQt). I would appreciate your help regarding the following design problem. I have to develop a treeview which would have 4 levels (For example, Country->County/Province->City->Town). The data for each level is stored in a seperate table in a SQL database. The treeview should be editable. It should have drag and drop, reorder functionalities. By reorder functionality I mean that the users would be able to reorder the branches of a node by dragging and dropping. (In our example, towns of a city would appear in a particular order that the user wants.) I was thinking of implementing QAbstractProxyModel with four different QSqlQueryModel, but then when reordering is allowed mapping between the indices looks a bit complicated. What is the best way to implement this? I was thinking of having a column in the respective database tables to store the order of the branches, but then different users might want different orders. It is therefore good to store the sort order in a session file. As a result I am thinking of implementing QAbstractItemModel and store the tree structure locally, but then keeping the database and the local copy of the tree in synchronisation becomes a bit difficult… I would appreciate your suggestions and comments . Thank you in advance, velum.

Viewing all articles
Browse latest Browse all 18427

Trending Articles