Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QTableview Viewport Problem
Forum Updated to NodeBB v4.3 + New Features

QTableview Viewport Problem

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 1.4k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nitishjo
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @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?

      157

      N 1 Reply Last reply
      0
      • p3c0P p3c0

        @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?

        N Offline
        N Offline
        nitishjo
        wrote on last edited by
        #3

        @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

        p3c0P 1 Reply Last reply
        0
        • N nitishjo

          @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

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @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:
          view->visualRect(model.index(0,0));
          view->visualRect(model.index(0,1));
          

          157

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved