Important: Please read the Qt Code of Conduct -

QTableview Viewport Problem

  • When in Qtableview if we have more than 10 columns how do we get column number visible in the current viewport when we scroll horizontal scrollbar

  • Moderators

    @nitishjo Which tableview are you referring QtQuick's TableView or C++ QTableView ? Also can you provide more details of what you are trying to do?

  • @p3c0 I am using C++ Qtableview. I am trying to say that if i have suppose 10 columns and i move the horizontal scroll bar to right to view 10th column then i need the current column numbers which are visible in the viewport

  • Moderators

    @nitishjo Not aware of a built-in method as such. But may be you can try iterating through columns and checking its coordinates(in your case x) are inside viewport's area. For that you have:

    • viewport's dimensions using size()
    • each columns area using visualRect can be calculated as:

Log in to reply