PDA

View Full Version : seeking advice on using model/view in my next project



vokov
24th October 2012, 04:51
Hey everyone! I am looking for some advice on organizing my next project.

Basically, I want an app that stores train schedules (involving ~20,000 trains) in a model and displays it in widgets which are subclasses of QTreeView, QTableView, and QGraphicsView.

(1) The tree widget would display departure cities at the top level, arrival cities on the next level, and finally the corresponding trains.

Like this:


Paris

Athens

train A
train B
train C




(2) The table widget would display arrival/departure times and other data for the selected trains. Train selection can be facilitated by adding check boxes to the above tree widget.

(3) Graphics widget would visualize the route of the selected trains on a map.

Would this be possible to implement using Qt's model/view architecture? If so, what model should I choose? Is it possible (without too much hacking) to make a proxy model between QTreeView widget and a table model? If not, are the any alternative approaches?

I would really appreciate any suggestions! Thanks!

boudie
24th October 2012, 09:45
I'm working on something that looks quite similar. See attached screenshot.
8346
I subclassed QAbstractItemModel and used two QTreeViews to show the data. I found that easier to synchronize than using a QTreeView and a QTableView.

vokov
24th October 2012, 17:25
Makes sense. I've also found a discussion on how to use QAbstractItemModel with QGraphicsScene (http://invalidmagic.wordpress.com/2010/10/05/qgraphicsscene-used-as-a-qabstractitemview-iii/). So looks like this is the way to go. Thanks!

Your app looks really nice. Did you customize the widgets or that's their native Ubuntu look? I mostly work with mac and the widgets look much crappier.

boudie
24th October 2012, 22:47
It's native Ubuntu 10.04 (Gnome desktop) with the Ambiance theme.