PDA

View Full Version : Complicated QListView



ComaWhite
19th May 2010, 18:05
I have a complicated QListView. It's just like a QColumnView. Where I have 3 views that use 1 model to get the information. So when 1 changes the others change with it. I cannot use a QColumnView due to each view being in separate tabs in the configuration dialogue.

I'm trying to implement a custom QAbstractItemModel on the QListView instead of the List model. The problem is, that the parents don't really work the way they are in a normal TreeView. I have some of it figured out. But some I have no idea how to go about doing 3 models to interact with each other on the same model. Because the data has to be persistent between each other. So if one changes the other has to change with it.

Currently, I do not know how to tell which view it is calling what data. Do I use the parent() at all? When I insert/remove data does the parent QModelIndex() be used and what not.

tbscope
19th May 2010, 18:25
I think, but I'm not sure, that you're looking for setRootIndex
http://doc.qt.nokia.com/4.6/qabstractitemview.html#setRootIndex

When you select an item in your first listview (in the first tab), then use that item as the rootitem for your second listview (in the second tab) etc.
Or did you mean something else?

SixDegrees
19th May 2010, 18:26
I'm not sure I understand your question, but if you want three seperate views on the same data, create one model and set it on those three different views. When the model changes, all attached views will change to reflect the new data, but the data will be maintained in a single place - the model.

ComaWhite
20th May 2010, 17:17
Yeah, each view will be displaying separate data. I'm going to be using a QAbstractItemModel. The only issue is. It's a little unusual for this time of data I'm trying to work with. Trying to write the parent function in it and I'm confused on how to write it. Since the data will be stored like so.



QList<QPair<Identity*,NetworkManager*>>


And each Network is contained in the NetworkManager.

While a traditional Tree model will just use a single item for the tree.

simin
21st May 2010, 07:12
hi
i wrote a QListView. i want to show me the item when i clicked on a member of listview.
i have QString string;
i mean my listview has some QStrings(forexample 5 Strings) when i clicked on 3th item, strign changed to that item.
what's its signal?how can i write connect ?(sorry i dont know english very well)
thanks