#include "table.h" int Table::sizeHintForColumn(int column) const { auto item = horizontalHeaderItem(column); if(!item) return QTableWidget::sizeHintForColumn(column); int width = item->data(0x99).toInt(); if(!width) return QTableWidget::sizeHintForColumn(column); auto header = horizontalHeader(); if(header->sectionResizeMode(column)!=QHeaderView::ResizeToContents) return QTableWidget::sizeHintForColumn(column); int colCnt = columnCount(); int remainWidth = header->width(), stretchWidth = width; for(int cc=0; ccsectionResizeMode(cc)==QHeaderView::ResizeToContents) stretchWidth += item->data(0x99).toInt(); else remainWidth -= item->data(0x99).toInt(); } if(remainWidth<=0) return QTableWidget::sizeHintForColumn(column); return width * remainWidth / stretchWidth; }