Nominate our 2022 Qt Champions!

How to find out if an item of QTreeView is visble or not?

  • I need to ensure an item is visible. I do that by calling scrollTo. The problem is, even if the item was visible, scrollTo will still scroll the view slightly so that the item in question is at the bottom of the view region - even though I use the default second parameter, QAbstractItemView::EnsureVisible. I want to avoid that unneccessary movement, which I can do by not calling scrollTo in the first place if I don't have to.

  • Moderators

    You can use visualRect for that. It's gonna be invalid if the item is not visible.

Log in to reply