PDA

View Full Version : Model for a (custom) calendar widget



asieriko
5th April 2012, 10:34
Hello,
I want to create a calendar application, but not whit the QCalendarWidget because I want to display some texte on each day.
7565
Anyway, I want to load my data into a model, and then ask for it from the view.
I've been reading and testing a lot, but still I can't figure a way to do this.

Do you have any tips on this?

Thank you!

Asier

AlekseyOk
5th April 2012, 11:36
1. Create view class inherited from QListView or QTableView.
2. Create appropriate model class.
3. Setup delegate for view.
4. Make money on your application)

asieriko
5th April 2012, 13:43
Thank you,
I've tried what you said (except for the 4th point ;-))
But I don't know what's the best model for such data, and how can I select only the data (rows) for certain dates.
Because, as I have understood, a view ask for data, with a index, that is a x,y coordinate (in a table).
I've thougth that maybe I could use a treemodel, being the parent nodes the dates, and the child nodes the data (one or more) for that specific date. But, how can I covert the date to a index?

(I don't think that this is very easy, since I've been looking for examples or already done similar widgets, and I have only found one in korganizer for KDE, but I got lost in the code)

AlekseyOk
2nd May 2012, 11:27
1. Try to use simple *ItemModel.
2. To determine selected items in view use selectedIndexes() function.