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

Text elide in QTableView is incorrect.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P3: Somewhat important
    • None
    • 5.15.2
    • Widgets: Itemviews
    • None
    • macOS

    Description

      main.c++ which will reproduce the bug:

      #include <QApplication>

      #include <QTableView>

      #include <QHeaderView>

      int main(int argc, char** argv)

      {

          QApplication app(argc, argv);

          auto* view = new QTableView;

          class Model: public QAbstractItemModel {

          public:

              QModelIndex index(int row, int col, const QModelIndex& index) const override

              {

                  if (!index.isValid() && row == col && row == 0) return createIndex(0, 0);

                  return {};

              }

              QModelIndex parent(const QModelIndex& index) const override { return {};}

              int rowCount(const QModelIndex& parent) const override

              {              if (!parent.isValid()) return 1;              else return 0;         }

              int columnCount(const QModelIndex& parent) const override
              {            if (!parent.isValid()) return 1;           else return 0;        }
              QVariant data(const QModelIndex& index, int role) const override

              {

                  if (role == Qt::DisplayRole && index.isValid())

                      return tr("The data of items in models are assigned an ItemDataRole;"

                                "each item can store a QVariant for each role.");

                  return {};

              }

          };

          

          view->setTextElideMode(Qt::ElideMiddle);

          view->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

          view->setModel(new Model);

          view->show();

          return app.exec();

      }

      The text may display in the cell:

      The data of i...s in models ...

      The data of items in ...

      The ellipsis always appear at right if space is unavailable, and ellipsis at middle may not appear.

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            tracejesus 穆 彤东
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes