Use a QTreeView instead of a QTreeWidget. You can set the same instance of your model to multiple instances of QTreeView.
See: http://qt-project.org/doc/qt-5.0/qtw...qtreeview.html
Use a QTreeView instead of a QTreeWidget. You can set the same instance of your model to multiple instances of QTreeView.
See: http://qt-project.org/doc/qt-5.0/qtw...qtreeview.html
OK.
I read about QTreeView... and don't find any simple answer. What i need to do is make a tree trom data stored in table
Qt Code:
NAME | ParaneID | ID | Description foo | 0 | 1 | Some entry bar | 1 | 2 | another entryTo copy to clipboard, switch view to plain text mode
Qt Code:
name DESC |-> FOO Some entry |-> BAR another entryTo copy to clipboard, switch view to plain text mode
I need to store in my model Name, description and ID. In QTreeWidget I create a item, setText (0,name); (1,ID); (2,desc) and add the item as root (if parent = 0) or as a child of different entry. How can I do it with QStandardItemModel? Only thing I found is an example where are entries with children having only one column... I need multiple columns in children.
Sory for 2 posts in row but I don't know how edit last one...
The thing I was missing is
Qt Code:
To copy to clipboard, switch view to plain text mode
function
QTreeWidgets are independent of each other with separate data and selections. A shared selection is only really sensible if the underlying data model is also shared.
If you want the same data presented in three view then you should use QTreeView and a separate model. You can build a usable tree model with QStandardItemModel or write your own custom model.
If you have three views sharing the same model and want the same current and selected items in each then point them all at the same QItemSelectionModel (i.e. share one).
Bookmarks