qt - Finding out how many items fit in the QTreeView (number of rows visible on the screen) -
i'm sure there's easy way number, can't find any.
it can't determined empty view because can vary depending on items' content. if there items in view, can calculate qabstractitemview::visualrect
, intersect viewport()
's rect()
see if particular item visible. can iterate on rows , check if item visible. example:
for(int row = 0; row < view.model()->rowcount(); row++) { if (!view.visualrect(view.model()->index(row, 0)).intersects(view.viewport()->rect())) { return row; } }
however works if have top level items , have enough items fill viewport.
alternatively, can call view.indexat(qpoint(0, 0))
, view.indexat(qpoint(0, view.viewport()->height()))
, compare indexes. if these indexes don't share same parent, counting rows become troublesome.
Comments
Post a Comment