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



  • 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.


  • Moderators

    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 );
    @



  • Thank you Raven I used your solution


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.