Results 1 to 2 of 2

Thread: View with custom delegate not reacting to update() an repaint()

  1. #1
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default View with custom delegate not reacting to update() an repaint()

    Hello again,
    my problem is the following: I have a custom sql table model inheriting from QSortFilterProxyModel and a view with a custom delegate onto this. The custom delegate colors certain elements in the table differently (to be exact, new table entries get colored red for 40 seconds). The problem is that the view won´t update using update() or repaint().
    So when a new entry is added to the sql table, it shows up in my model. After it shows up there it is detected and the row is marked as "special" for the delegate. Now I call update() with the intention that the view will color the row red as expected ... but it doesn´t, basically nothing happens.
    OTOH, if I force a resize call by resizing the window, or if i do another update of the underlying model, triggering an automatic update of the view, everything works as expected. It of course would look a bit dumb to let screen resize everytime I need an update .Is there anything special to consider when using custom delegates? I already checked multiple times that I haven´t accidently disabled updates or stuff like that.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: View with custom delegate not reacting to update() an repaint()

    You have several options to make the view update accordingly.

    Inform the change though the model:
    - void QAbstractItemModel::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight) [signal]
    - void QAbstractItemModel::reset() [protected]

    Or you can either make the view update itself by calling:
    - void QAbstractItemView::setDirtyRegion(const QRegion& region) [protected]
    - void QAbstractItemView::reset() (this makes the whole view updated i think)

    There might be even more ways to do that. Calling just update() or repaint() won't do the trick since the view doesn't know that the model has changed in any way.
    J-P Nurmi

  3. The following 2 users say thank you to jpn for this useful post:

    e79ene (13th November 2011), topher (2nd December 2010)

Similar Threads

  1. Replies: 6
    Last Post: 20th April 2006, 10:23

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.