Results 1 to 14 of 14

Thread: Models and Delegates

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Models and Delegates

    Quote Originally Posted by bgeller View Post
    The docs and examples I have read clearly say you can use data() in the model or paint() in the delegate.
    It's not "or", it's "and". Always both routines are used. You can't choose between the two, you always use both.


    Quote Originally Posted by bgeller View Post
    I believe I understand what you are saying. My issue was if there is a preferred place to make the alterations of what is displayed. As a test I was able to make the changes in both methods. So this seems to be a matter of preference.
    More like a matter of effect you wish to obtain. When you change the way the model returns data you affect all places where the data is used. When you change the delegate you only affect the view the delegate is installed on. Imagine you have two views showing the same data. If you modify the "looks" of the data in the model, both views will display the same thing, if you install two different delegates on each of the views, the display will differ. Also some things can't be done by changing the model - i.e. try making it display some text and two icons besides it (one on the left of the text and the other on the right of the text).


    I am impressed at how much flexibility the model / delegate classes provide.
    They are fine when dealing with simple situations but at some point you start stumbling against the wall. The architecture is already reaching its limits but hopefully it will be replaced (or complemented) by ItemViewsNG within a year or so.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Models and Delegates

    I can put color information in the data() method.
    But simply having color information wont paint it in that color ! Unless your delegate knows about it. But still its the delegate that actually draws things.
    I can put color information in the data() method. What I really believe is going on, is that paint() in the delegate asks the model for information.
    You are getting it right. The model is the data provider, delegate the painter.

Similar Threads

  1. Trying to use delegates...
    By foahchon in forum Qt Programming
    Replies: 7
    Last Post: 28th August 2009, 07:17
  2. sql models
    By damiano19902 in forum Newbie
    Replies: 1
    Last Post: 4th June 2009, 07:18
  3. Proxy models and slection models
    By amunitz in forum The Model-View Framework
    Replies: 1
    Last Post: 23rd September 2008, 14:35
  4. Models, delegates or views and how?
    By maddogg in forum Newbie
    Replies: 3
    Last Post: 9th November 2007, 13:59
  5. delegates
    By hgedek in forum Newbie
    Replies: 3
    Last Post: 24th October 2007, 19:00

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
  •  
Qt is a trademark of The Qt Company.