Hi ladies and gents, I have a QTableView with 4 columns and I would like to permanently resize the second column to 50% the entire width of the QTableView. I thought this would be something easy to figure out but it has proven otherwise. I have attached a screenshot of what I am trying to achieve below. As can be seen in the screenshot below, the second column is 3-times longer than the first and the third column.Selection_001.png
Qt Code:
  1. MainWindow::MainWindow(QWidget *parent) :
  2. QMainWindow(parent),
  3. ui(new Ui::MainWindow)
  4. {
  5. ui->setupUi(this);
  6. ui->tableView->setColumnWidth(1, 900);
  7. model = new QStandardItemModel(74, 4, ui->innertabWidget);
  8. this->setWindowTitle("Tender Bot");
  9. QFile sitesFile("websites.txt");
  10. if(!sitesFile.open(QIODevice::ReadOnly | QIODevice::Text))
  11. {
  12. qDebug() << "Something went wrong, file did not open" <<endl;
  13. }
  14. else
  15. {
  16. QTextStream out(&sitesFile);
  17. int count = 0;
  18. while(!out.atEnd())
  19. {
  20. QModelIndex index = model->index(count, 0, QModelIndex());
  21. model->setData(index, sitesFile.readLine(0).simplified());
  22. count++;
  23. }
  24. }
  25. model->setHeaderData(0, Qt::Horizontal, "Websites");
  26. model->setHeaderData(1, Qt::Horizontal, "Downloaded");
  27. model->setHeaderData(2, Qt::Horizontal, "Date");
  28. model->setHeaderData(3, Qt::Horizontal, "Buttons");
  29. ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
  30. ui->tableView->setModel(model);
  31. }
To copy to clipboard, switch view to plain text mode 
I thought line 6 in the code snippet above would achieve my desired outcome but it doesn't work.

Please assist.