Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-7567

QStyledItemDelegate::displayText() does not get called for null values

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 4.7.4
    • 3.x
    • Documentation
    • None
    • 71e6e429ea6afc97dfa6bb5d158a751a4a092eea

    Description

      How to reproduce
      ==============
      1. Derive from QStyledItemDelegate and reimplement displayText() to always display some constant string,
      2. Take a table model,
      3. Insert a column (which will cause the column to be filled with null values initially),
      4. Plug the model into a view,
      5. Set an instance of your custom QStyledItemDelegate as the delegate for the newly inserted column.

      Expected result
      ============
      The inserted column should show the constant string from your custom displayText() method

      Actual result
      ==========
      displayText() isn't called at all, probably because of the value.isNull() checks in initStyleOption (see http://qt.gitorious.org/qt/qt/blobs/master/src/gui/itemviews/qstyleditemdelegate.cpp#line381 for example).

      Proposed fix
      ==========
      Mention in the documentation for displayText() that it will be skipped if the QVariant for that model index isNull().

      Known workaround
      ===============
      Let your model return empty QStrings for the problematic indices (so that displayText gets called).

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            dm Geir Vattekar
            mikhas Michael Hasselmann
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes