Brilliant, thanks. I knew it was possible, but didn't know what it was called.
Brilliant, thanks. I knew it was possible, but didn't know what it was called.
It's called Model/View Programming and it is very very good documented at the docs: http://doc.trolltech.com/4.5/model-v...ogramming.html.
Maybe it is enough for you using a standard model but with a custom delegate for displaying the data.
squidge (12th October 2009)
Its fine to read the docs, but until you know what your looking for, its kinda difficult. I don't read the docs like a book and just jump to the pages of interest.
I looked up the model programming and seemed quite easy. I threw together a class and assigned it to the widget. Works brilliant, just as I wanted it to. However, I would be interested to know how the widget knows if some data is changed. For example, if the widget is showing items 1 - 30 on a screen, and then the data for item 10 changes in the background, how does the widget know to redraw?
Don't know if a delegate would work as I need control over the row count. I will require painting later on though as I'll need to change the font color of some items. Is this a good use of delegate? I was thinking of overriding the paint method, but not checked if thats possible yet.
There is a signal dataChanged(QModelIndex, QModelIndex) in every model implementation and be sure when implementing your own mode to emit this signal everytime that some data chenges in background - this would notify view about need to redraw changed indexes (indices?).
I would like to be a "Guru"
Useful hints (try them before asking):
- Use Qt Assistant
- Search the forum
If you haven't found solution yet then create new topic with smart question.
squidge (12th October 2009)
Bookmarks