How to "share" a QTreeWidget
Hi.
I'm working on a application that uses couple of windows, and couple of them uses the same QThreeWidget, my question is
Is there a simple way to share the same qtreewidget (or only the information of item expands and selections) between different QDialogs?
Re: How to "share" a QTreeWidget
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
Re: How to "share" a QTreeWidget
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
Code:
NAME | ParaneID | ID | Description
foo | 0 | 1 | Some entry
bar | 1 | 2 | another entry
Code:
name DESC
|-> FOO Some entry
|-> BAR another entry
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.
Re: How to "share" a QTreeWidget
Sory for 2 posts in row but I don't know how edit last one...
The thing I was missing is
function :)
Re: How to "share" a QTreeWidget
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).