문제

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