Details
-
Bug
-
Resolution: Won't Do
-
P3: Somewhat important
-
None
-
5.15.2
-
None
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.