Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top