[Qt-interest] MVC Questions and Syncing QTreeView and
Gururaj Deshpande
gururaja.deshpande at gmail.com
Sat Jan 15 18:03:18 CET 2011
Hello
Did you try using the
setSelectionModel(QItemSelectionModel*) method ?
e.g tableView->setSelectionModel(treeView->selectionModel())
This will set the selection in Tree view to tableView as well.
-Dheerendra
> Message: 5
> Date: Tue, 11 Jan 2011 16:19:48 +0000 (UTC)
> From: lbutler3 at comcast.net
> Subject: [Qt-interest] MVC Questions and Syncing QTreeView and
> QTableView
> To: qt-interest at qt.nokia.com
> Message-ID:
> <
> 1341967949.123979.1294762788475.JavaMail.root at sz0009a.westchester.pa.mail.comcast.net
> >
>
> Content-Type: text/plain; charset="utf-8"
>
> I've got some questions about how to keep multiple views of the same data
> in sync.
>
> I'm building an application to organize 3D models and manipulate meta-data.
> Think about grouping objects together into collections (and collections of
> collections) as well as setting attributes (like color) of the leaf items.
>
> The heirarchy is displayed and edited using a QTreeView which has a data
> model class derived from QAbstractItemModel to give it access to data to
> display. I need to display a table of "parts" (the leaves of the heirarcy)
> and their associated properties (eg. color) for users to edit. I can create
> a table model derived from QAbstractItemModel.
>
> The question is how to keep these two data models in sync. They both have
> selection models that need to be kept in sync. Contrary to the tutorials and
> examples I've seen, neither datamodel seems appropriate to "own" the
> underlying data. They just provide an interface for the Q*Views. For
> example, the rendering pipeline needs access to the application-native
> representation of the data for drawing the 3D display. So how do we map
> QModelIndex items from one view to another? How do we keep selection models
> in sync? And most crucially: Where does this processing take place? I accept
> that the classes derived from QAbstractItemModel are a part of the "data
> model" (M from Model-View-Controller). Does the controller take the
> responsibility of reaching down into both models to manipulate their
> selections? I guess I can see this when doing operations like cut-paste, but
> for selection I was hoping there might be a cleaner way.
>
> Your counsel would be greatly appreciated.
>
> Lee
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.qt.nokia.com/pipermail/qt-interest/attachments/20110111/7765c4fc/attachment.html
>
> ------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>
> End of Qt-interest Digest, Vol 2, Issue 50
> ******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110115/ae7f5360/attachment.html
More information about the Qt-interest-old
mailing list