[Qt-interest] Model/view programming
David Heremans
david.heremans at intersoft-electronics.com
Thu Aug 25 11:16:17 CEST 2011
Hello,
I'm trying to create my own datamodel and proxymodel but I'm having some
serious trouble getting it all to 'play nice', the thing keeps acting
weird and segfaulting.
Does anybody knows some good in-dept tutorials/documentation about this ?
I'm trying to create a proxy that re-arranges a 'ps -ef'-like table into
a tree view depending on PID and PPID. Only the PPID and PID fields in
the table can change so the proxy will have to rearrange them on-the fly
as data changes.
Allow me to throw in a bunch of different questions here.
Some of the issues I'm having:
- If I rearrange the tree then the treeview will suddenly collapse open
branches if the parent is removed. How can I prevent this? In the same
category, if I add children to a tree, is there a way to tell the view
to open the branch automatically?
- If I add rows then I have a line 'emit layoutAboutToBeChanged' but
does this make the beginInsertRows/endInsertRows methods superflous?
- If I have a QModelIndex in my proxy that I inserted that has no
equivalent in the sourceModel. What value does the MaptoSource needs to
return?
- I tried the modeltest, is it normal that it tries to access the
topIndex'(0,0,QModelIndex())' even if the rowcount of the model returns 0?
- I noticed that if I set the treeview to select rows only, but use the
selectionModel from the view to set a specific Qmodelindex, then this
selects only one cell in the view instead of the row. How do I avoid this?
- I came across a thing called PersistentIndexes, I'm not using this in
my program. It is to say, at least not specifically programmed by me,
are the view using this stuff. A good explication about what I have to
do with these things would be nice since the documentation does not
really tell you what (and how) to implement a new model with regard to
those things.
Any help is greatly appreciated.
rgds
David H
More information about the Qt-interest-old
mailing list