Since I had the same problem (rows' heights) with a QTreeView now, I did some digging through Qt's source code.
Look what I've found:
.../qtbase/src/widgets/itemviews$ grep -n sizeHintChanged *
qabstractitemdelegate.
h:120: void sizeHintChanged
(const QModelIndex &);
qabstractitemview.
cpp:834: disconnect
(d
->itemDelegate,
SIGNAL(sizeHintChanged
(QModelIndex)),
this,
SLOT(doItemsLayout
()));
qabstractitemview.
cpp:843: connect(delegate,
SIGNAL(sizeHintChanged
(QModelIndex)),
this,
SLOT(doItemsLayout
()), Qt
::QueuedConnection);
.../qtbase/src/widgets/itemviews$ grep -n sizeHintChanged *
qabstractitemdelegate.cpp:163: \fn void QAbstractItemDelegate::sizeHintChanged(const QModelIndex &index)
qabstractitemdelegate.h:120: void sizeHintChanged(const QModelIndex &);
qabstractitemview.cpp:834: disconnect(d->itemDelegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout()));
qabstractitemview.cpp:843: connect(delegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout()), Qt::QueuedConnection);
To copy to clipboard, switch view to plain text mode
That's all. See how the QModelIndex that is passed to sizeHintChanged is ignored? Any sizeHintChanged signal just triggers a relayout.
Even more interesting is the doItemsLayout() slot. It is public and available in all of Qt's item view widgets, but it is not documented. That's exactly what I was looking for
Someone asked if he could rely on that on another forum a few years ago. So I'm going to repeat the question here.
Bookmarks