Results 1 to 8 of 8

Thread: Display different values in model versus proxy with a delegate

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Display different values in model versus proxy with a delegate

    I have a little experience with delegates but this behavior is very confusing. Can someone explain how the Qt:: DisplayRole value is getting changed in the model without the proxy delegate paint() function being called?
    I am afraid that you will have to tell us because it is your code.

    The Qt::DisplayRole of the standard models reflects a default conversion from the QVariant value you get on the Qt::EditRole. If there is an implicit QString conversion from whatever you are putting on the data then that is probably what you will get in the Qt::DisplayRole. In custom models you get complete control over what each role returns to the model consumers.

    View delegates have nothing to do with the data returned by models. Delegates are attached to a view and called when a view needs to display an item. The QStyledItemDelegate::paint() method should render the value returned from the model using whatever visual is appropriate. The delegate can do some rudimentary changes to what it displays using the QStyledItemDelegate::displayText() method, but this does not alter the model or the data seen anywhere else.

  2. The following user says thank you to ChrisW67 for this useful post:

    mclark (1st November 2010)

Similar Threads

  1. Item delegate displaying enumerated values
    By mclark in forum Qt Programming
    Replies: 2
    Last Post: 24th September 2010, 16:31
  2. Proxy model with multiple sources
    By Nightfox in forum Qt Programming
    Replies: 0
    Last Post: 25th August 2010, 08:56
  3. A Totalling Proxy Model?
    By ChrisW67 in forum Qt Programming
    Replies: 2
    Last Post: 7th April 2010, 03:06
  4. Model, View and Proxy
    By No-Nonsense in forum Qt Programming
    Replies: 2
    Last Post: 21st November 2006, 08:50
  5. Model and Proxy
    By larry104 in forum Qt Programming
    Replies: 1
    Last Post: 4th August 2006, 21:05

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.