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

Modifying a font in style delegate doesn't work when text is elided

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.12.2, 5.14.0 Alpha
    • 4.8.5, 5.1.1
    • Widgets: Itemviews
    • None
    • Windows, Linux
    • 25133a1b77c059e32760f3d288c985183d86da4a (qt/qtbase/5.12)

    Description

      Only happens if the item's font is overridden (even by its own copy like in the following example).

      #include <QApplication>
      #include <QStandardItemModel>
      #include <QStyledItemDelegate>
      #include <QTreeView>
      
      class Delegate : public QStyledItemDelegate
      {
      public:
          void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
          {
              QStyleOptionViewItem o = option;
              o.font.setBold(true);
              QStyledItemDelegate::paint(painter, o, index);
          }
      };
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          QStandardItemModel model;
          Delegate delegate;
          QStandardItem item("Quite a long string for testing font overriding");
          item.setFont(item.font());
          model.setItem(0, 0, &item);
          QTreeView view;
          view.setItemDelegate(&delegate);
          view.setModel(&model);
          view.show();
          return app.exec();
      }

      Attachments

        1. elided.png
          elided.png
          5 kB
        2. expanded.png
          expanded.png
          5 kB
        3. main.cpp
          1 kB

        Issue Links

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

          Activity

            People

              chehrlic Christian Ehrlicher
              orgads Orgad Shaneh
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes