Results 1 to 3 of 3

Thread: Custom tablemodel and delegates problem.

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Custom tablemodel and delegates problem.

    I have reviewed all the help related with delegates for table-model.
    I see table.setitemdelegate() (and the itemdelegateforcolumn and itemdelegate for row).
    If I use this approach, I need to set the data of items before the table was showed. ( as startdelegates does)
    But this is a problem for me.
    I have a custom tablemodel to retrieve data. I can detect the data request, but I dont know how to set the data for the delegate because the paint event of the delegates if triggered before any data request event...
    How can I fix this problem ? I'd need a data - role request that lets me set the right data .
    And I have a model that retrieves data from a internal store system designe to deal with ten of thousands rows of data.

    All the examples I see has not custom tablemodel.... (the items are added to the tableview.... )
    I need help on this..
    Thanks.

  2. #2
    Join Date
    Mar 2006
    Posts
    74
    Thanks
    1
    Qt products
    Qt3
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Custom tablemodel and delegates problem.

    In the model you signal that the data has changed with

    Q_EMIT dataChanged();

    in the setData() method and any other place the data can change.

    If you are doing things like sorting the data you will also need to emit/call

    layoutAboutToBeChanged()

    and

    layoutChanged()

    When you insert rows in your table you need to call beginInsertRows() ... endInsertRows() and a similar thing for removing rows. These are what signal the view that the model has changed and things in the view need up dating and that is when the delegate is used by the view.

    At least the above is what works for my custom view/model code.

  3. #3
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Custom tablemodel and delegates problem.

    Aha ! Thank you very much

Similar Threads

  1. TreeModel from TableModel
    By baray98 in forum Qt Programming
    Replies: 3
    Last Post: 21st May 2011, 01:06
  2. Problem with Delegates in QTreeWidget
    By DeRatizator in forum Newbie
    Replies: 1
    Last Post: 1st October 2010, 12:42
  3. Problem with Delegates in QTreeWidget
    By DeRatizator in forum Qt Programming
    Replies: 0
    Last Post: 1st October 2010, 11:42
  4. Compiling qt tablemodel
    By jmqt in forum Newbie
    Replies: 2
    Last Post: 15th June 2009, 07:47
  5. Refresh TableModel
    By abbapatris in forum Qt Programming
    Replies: 8
    Last Post: 7th March 2008, 14:55

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.