C++ (Qt)QSize treeViewContentsSize( QTreeView* tv ){ QScrollBar* vsb = tv->verticalScrollBar(); QScrollBar* hsb = tv->horizontalScrollBar(); QRect vr( tv->visualRect( tv->model()->index( 0, 0 ) ) ); return QSize( hsb->maximum() + hsb->pageStep (), ( vsb->maximum() + vsb->pageStep () ) * vr.height() );}
treeWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
treeWidget->height() + treeWidget->verticalScrollBar()->maximum());