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 resizesection does not work

[SOLVED] QTableview resizesection does not work

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.0k 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.
  • S Offline
    S Offline
    sharon_obl82
    wrote on last edited by
    #1

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

    @

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Saugglocke
      wrote on last edited by
      #2

      Hey,

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

      bb

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sharon_obl82
        wrote on last edited by
        #3

        oh right, thanks very much!

        1 Reply Last reply
        0
        • JeroentjehomeJ Offline
          JeroentjehomeJ Offline
          Jeroentjehome
          wrote on last edited by
          #4

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

          Greetz, Jeroen

          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