Need to find the total height of a QListView, not its viewport's height.

This is simple with a QScrollArea which is derived from the same base class QAbstractScrollArea as QListView:

QScrollArea *sa;
sa->widget()->height();   // total height
sa->viewport()->height(); // viewport height

But I could not find an equivalent function for QListView. In case such a convenience function is lacking, what would be the best way to calculate the total height?

有帮助吗?

解决方案

Well, it's not a good way, but it's the only working way I know. Use view->visualRect(index).bottom(), where index is the last item's index. But it can be inaccurate. For example, if you want to set the view's height based on this value, you'd better add several pixels.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top