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] Can I hide all the Columns of QTableView?
Forum Updated to NodeBB v4.3 + New Features

[Solved] Can I hide all the Columns of QTableView?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.4k Views 1 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.
  • H Offline
    H Offline
    Hareen Laks
    wrote on last edited by
    #1

    Hi,

    I created a model based QTableView and set the QSqlQueryModel as it's model.
    I'm feeding data to the model from a database table.

    That table consists 25 columns and I want to show only 5 columns in tableview.

    I'm asking that without writing @ui->tableview->hideColumn ( 0 )@

    twenty times, can I simply hide all 25 columns at once and show five columns which are required.

    Thank you.

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      you could use QSortFilterProxyModel and filter out the columns.

      But calling hideColumn() in a loop would definitely the fastest way.

      @
      QList<int> columnsToHide;
      //fill list
      foreach( int col, columnsTohide );
      ui->tableview->hideColumn ( col );
      @

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hareen Laks
        wrote on last edited by
        #3

        Thank you Raven I used your solution

        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