I agree, model-view docs don't cover very well if at all writing a custom view. Custom models and delegates are common but people rarely need to write custom views.
Edit: PS. Just ask if you have any specific questions about certain methods or so..![]()
I agree, model-view docs don't cover very well if at all writing a custom view. Custom models and delegates are common but people rarely need to write custom views.
Edit: PS. Just ask if you have any specific questions about certain methods or so..![]()
Last edited by jpn; 21st January 2008 at 19:32.
J-P Nurmi
Well I'm writing some sort of a Form View for my ToDo app. The app works with a database which contains a bunch of tasks. A task consists of a title, an rich text formatted description and some more data about when it should be finished.
The app will have two views: a Form View and a standard QListView with a header, I guess.
The form view consists of various widgets. It's got a model set to it which contains the current selection of the QListView, i.e. the current task (title, description, date it should be finished, ...).
The list view has a different model set to it, an enumeration of all tasks in the database (title and id only).
My main questions are:
Is it a good idea to make a form view or should I use something else?
When are the following functions called:
- indexAt(const QPoint & point) const
- scrollTo(const QModelIndex & index, ScrollHint hint)
- visualRect(const QModelIndex & index) const
- moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
- visualRegionForSelection(const QItemSelection & selection) const
Many thanks in advance
Have you noticed QDataWidgetMapper? It provides mapping between model and widgets. With help of QDateWidgetMapper it should be easy to create any kind of form which contains widgets working directly on top of database model.
J-P Nurmi
defumar (22nd January 2008)
Hadn't noticed it, no. Will have a look at it right now
Edit: Looks very useful, I now understand why so little people want to make their own view![]()
Last edited by defumar; 22nd January 2008 at 11:14.
Pointer operations like clicking and selection.
All kinds of ensureVisible, scrolling the viewport and changing item focusscrollTo(const QModelIndex & index, ScrollHint hint)
Mainly redrawing.visualRect(const QModelIndex & index) const
Editing and key input events.moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
Redrawing.visualRegionForSelection(const QItemSelection & selection) const
When in doubt, just use grep.
defumar (22nd January 2008)
Thanks you two, oh and grep and Qt are awesome :-)
Can't believe I've been messing around with MFC for so long![]()
Bookmarks