How to force QAbstractItemView recalculate items sizeHints

☆樱花仙子☆ 提交于 2019-11-28 01:56:23

After digging in Qt source code, I found that scheduleDelayedItemsLayout() function is solving the issue on my side.

This is a bit of a guess, but does setting your QListView's resize mode help?

listView->setResizeMode( QListView::Adjust );

Experiencing the same issue in November 2017...

The only way I found to resolve it is this ugly hack :

   QSize size = listView->viewport()->size();
   size.setHeight(size.height()+1);
   listView->viewport()->resize(size);

   size.setHeight(size.height()-1);
   listView->viewport()->resize(size);

It forces a resize on the listview, which itself refreshes its row sizes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!