Results 1 to 3 of 3

Thread: QAbstractItemDelegate editing behavior confusion

  1. #1
    Join Date
    Dec 2013
    Posts
    14
    Thanks
    2
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QAbstractItemDelegate editing behavior confusion

    referring to Qt4.8... i'm utterly confused about what the docs say how a custom delegate editor shold work and what i observe instead.

    my requirements: a custom line editor that only submits its value to the model on particular user action, but not i.e. just on focus out. i of course have all i need to accomplish that, so i only need to wrap the delegate around my custom line editor in a way it fits my needs, but...

    the docs say in particular:
    http://doc.qt.io/qt-4.8/qabstractitemdelegate.html#setModelData
    Sets the data for the item at the given index in the model to the contents of the given editor.

    The base implementation does nothing. If you want custom editing you will need to reimplement this function.
    and for http://doc.qt.io/qt-4.8/qabstractitemdelegate.html#commitData
    This signal must be emitted when the editor widget has completed editing the data, and wants to write it back into the model.
    i admit, english is not my native language, but for me this means that if i don't reimplement setModelData and don't explicitly send commitData in my custom delegate, then nothing will ever happen to the underlying model, no matter what the editor does.

    in my case*) this isn't true. if i create my line editor widget in createEditor(...) and do nothing of the above, the base class still magically updates the model data to the last line editor value as soon the editor is destroyed (what i explicitly wanted to avoid)

    *) note: i write a plugin for a host that _might_ use modified Qt sources, so i'm really keen to know if the behavior i doubtlessly observe here is Qt standard and just the docs are completely misleading, or if some other strange things are going on...

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QAbstractItemDelegate editing behavior confusion

    And your delegate derives directly from QAbstractItemDelegate?

    Because its setModelData() does indeed not do anything: http://code.woboq.org/kde/qt4/src/gu...K11QModelIndex

    Cheers,
    _

  3. #3
    Join Date
    Dec 2013
    Posts
    14
    Thanks
    2
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QAbstractItemDelegate editing behavior confusion

    AH

    thanks for the "pointer"!

    ... too much inheritance, to much night hours. in fact there is a QItemDelegate somewhere down the road, and all the editor factory stuff takes place.
    gruß aus wien

Similar Threads

  1. Replies: 11
    Last Post: 13th February 2013, 23:26
  2. QAbstractItemDelegate and QLinearGradient
    By toutarrive in forum Qt Programming
    Replies: 2
    Last Post: 12th February 2010, 17:20
  3. about QAbstractItemDelegate
    By drizzlefsh in forum Qt Programming
    Replies: 4
    Last Post: 11th September 2009, 07:01
  4. Replies: 7
    Last Post: 30th August 2009, 22:58
  5. Use of QAbstractItemDelegate::closeEditor
    By jml in forum Qt Programming
    Replies: 3
    Last Post: 3rd August 2007, 22: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
  •  
Qt is a trademark of The Qt Company.