Results 1 to 3 of 3

Thread: custom widget and model

  1. #1
    Join Date
    Sep 2006
    Posts
    23
    Thanks
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Android

    Default custom widget and model

    Hello,
    I've (or better I'm creating) a new widget. It's like a calendar, and now I want to create a model to be able to populate easily that widget. I've been reading a lot of documentation about, but I don't get the solution. I'm thinking on a table model, maybe, and now I don't exactly know how to pass the data to the widget, I think that each day sould ask to the model what data does it have for that day, but I don't know how to do, al the references are about an index, and I don't know how to implement it.
    I think It should be something like this:
    Model:
    20081001 data1
    20081001 data2
    20081002 data
    20081003 data
    And the view should ask "give me the data from 20081001" for example.

    I hope you get my idea, and give me some solution.

    Thank you in advance

  2. #2

    Default Re: custom widget and model

    You have a model that provides a list or table of data from some data source:

    <Date> <Record>

    In order to filter only some records from that data, you can use a Proxy model:
    QSortFilterProxyModel. Read the documentation about it.

    However, it could become too complex architecture, if you have only 1 view and 2 models. In such a case, implement the filtering part inside your single model and provide only filtered data. The original full data will be still kept unchanged in the model source.

    The proxy model is handy, when you need two views: one of the original full data, and the other - of filtered data. This is described in the QSortFilterProxyModel documentation.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: custom widget and model

    I would suggest to create a two level model. First level stores dates, second level stores events under a particular date. Then it is easy to query the model for events on particular days.

Similar Threads

  1. QAbstractItemModel with QUndoStack
    By No-Nonsense in forum Qt Programming
    Replies: 7
    Last Post: 28th October 2012, 18:15
  2. How to display selected columns in QTableView widget.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:30
  3. How to show custom widget in TreeView's cell :-/
    By WolfMM in forum Qt Programming
    Replies: 2
    Last Post: 7th July 2007, 12:16
  4. Custom Model Class
    By mattjgalloway in forum Qt Programming
    Replies: 12
    Last Post: 4th June 2007, 18:30
  5. Custom widget in list view
    By fusoin23 in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2006, 15:09

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.