Results 1 to 2 of 2

Thread: Custom model and custom delegate

  1. #1
    Join Date
    May 2013
    Location
    Georgia,Tbilisi
    Posts
    32
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Custom model and custom delegate

    Hi all!
    I'm reading Johan Thelin's "Foundation of Qt Development" and my first big obstacle is understand model/view architecture. It seems a abit difficult for me. It confuses me.
    Let's say I have table 4x4, I want to change background of (2,0). What can I do? Create custom delegate or custom model,right?
    But which one to go? which is better?

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

    Default Re: Custom model and custom delegate

    If you want to change the background then how to do it depends on how your model is constructed. You can either teach your model to understand Qt::BackgroundRole so that the default delegate can ask for the background color and render it or you can implement a custom delegate that will know how to calculate the background color based on your model contents (or anything else that you want). In the latter case you will have to draw the background yourself.
    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.


Similar Threads

  1. Combine custom delegate and model data() roles
    By qlands in forum Qt Programming
    Replies: 1
    Last Post: 4th October 2011, 12:43
  2. Custom Model? Custom View? Custom Delegate?
    By Doug Broadwell in forum Newbie
    Replies: 4
    Last Post: 11th February 2010, 20:23
  3. Replies: 0
    Last Post: 1st February 2010, 11:00
  4. Question about custom view (or custom delegate)
    By skuda in forum Qt Programming
    Replies: 1
    Last Post: 21st September 2009, 20:06
  5. Replies: 0
    Last Post: 28th August 2009, 09:49

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