Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] QTableView - keep 1st column fixed size and non-scrollable
Forum Update on Monday, May 27th 2025

[Solved] QTableView - keep 1st column fixed size and non-scrollable

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 6.6k Views
  • 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.
  • A Offline
    A Offline
    amban
    wrote on last edited by
    #1

    Hi,
    I have a QTableView with 10 columns. I want to keep the 1st column size fixed and non-scrollable (similar to the column 0 showing row count). How can i do this ?

    Thanks a lot.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p91paul
      wrote on last edited by
      #2

      if you don't need column 0(row count), you can write column 1 in the vertical header (just like you do while changing column names), showing it in place of row numbers. (or you can subclass your model and override headerData() function to show 1st column instead of row numbers.
      If you need both row numbers and first column, I think you have to subclass QTableView, but I can't help you in this task.
      Paolo

      1 Reply Last reply
      0
      • A Offline
        A Offline
        amban
        wrote on last edited by
        #3

        Hi,
        Thanks for replying. I need both the columns.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          By default it is not possible (see "this":http://developer.qt.nokia.com/forums/viewthread/5358/ and "this":http://developer.qt.nokia.com/forums/viewthread/1978/ thread). I think there was an example on how to achieve a fixed column on the left by using two widgets in combination... But I don't recognize where...

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • A Offline
            A Offline
            amban
            wrote on last edited by
            #5

            This is the link http://doc.qt.nokia.com/latest/itemviews-frozencolumn.html
            It worked in my application.

            Thanks

            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