[SOLVED] QTableview resizesection does not work



  • Hi I wanted to set header size for my Qtableview by using resizesection but it doesn't work. I dont want to use the Stretch function cause the header is quite long and it will get truncated.
    Does anyone know what else can i use?
    Thanks

    @
    QStandardItemModel *model = new QStandardItemModel(0,9,this); //Rows and 9 Columns

           model->setHorizontalHeaderItem(0, new QStandardItem(QString(tr("Radio User Capabilities Profile Alias"))));
           model->setHorizontalHeaderItem(1, new QStandardItem(QString(tr("Radio User Capabilities Profile ID"))));
           model->setHorizontalHeaderItem(2, new QStandardItem(QString(tr("Security Group"))));
           model->setHorizontalHeaderItem(3, new QStandardItem(QString(tr("Primary Status Set Alias"))));
           model->setHorizontalHeaderItem(4, new QStandardItem(QString(tr("Secondary Status Set Alias"))));
           model->setHorizontalHeaderItem(5, new QStandardItem(QString(tr("Load Class Name"))));
           model->setHorizontalHeaderItem(6, new QStandardItem(QString(tr("BIC Profile Alias"))));
           model->setHorizontalHeaderItem(7, new QStandardItem(QString(tr("BOC Profile Alias"))));
           model->setHorizontalHeaderItem(8, new QStandardItem(QString(tr("User Group Alias"))));
          
           ui->tableView->horizontalHeader()->resizeSection(0,200);
           ui->tableView->horizontalHeader()->resizeSection(1,200);
           ui->tableView->horizontalHeader()->resizeSection(2,100);
           ui->tableView->horizontalHeader()->resizeSection(3,100);
           ui->tableView->horizontalHeader()->resizeSection(4,100);
           ui->tableView->horizontalHeader()->resizeSection(5,100);
           ui->tableView->setModel(model);
    

    @



  • Hey,

    you have to set the model first and then resize the header items.

    bb



  • oh right, thanks very much!



  • If this answer solved your problem, please place [SOLVED] before your first post.


Log in to reply
 

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